zipios++  2.0.2
Zipios++ – a small C++ library that provides easy access to .zip files.
zipios_common.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef ZIPIOS_COMMON_HPP
3 #define ZIPIOS_COMMON_HPP
4 
5 /*
6  Zipios++ - a small C++ library that provides easy access to .zip files.
7 
8  Copyright (C) 2000-2007 Thomas Sondergaard
9  Copyright (C) 2015 Made to Order Software Corporation
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 2 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25 
34 
35 #include <vector>
36 #include <sstream>
37 
38 
69 template<class Type>
70 void operator += (std::vector<Type>& v1, std::vector<Type> const& v2)
71 {
72  // make sure these are not the same vector or the insert()
73  // is not unlikely to fail badly; it is expected that the
74  // user does not try to duplicate an array...
75  if(&v1 != &v2)
76  {
77  v1.reserve(v1.size() + v2.size());
78  v1.insert(v1.end(), v2.begin(), v2.end());
79  }
80 }
81 
82 
83 namespace zipios
84 {
85 
86 
87 extern char const g_separator;
88 
89 
90 typedef std::ostringstream OutputStringStream;
91 
92 
93 typedef std::vector<unsigned char> buffer_t;
94 
95 
96 void zipRead(std::istream& is, uint32_t& value);
97 void zipRead(std::istream& is, uint16_t& value);
98 void zipRead(std::istream& is, uint8_t& value);
99 void zipRead(std::istream& is, buffer_t& buffer, ssize_t const count);
100 void zipRead(std::istream& is, std::string& str, ssize_t const count);
101 
102 void zipRead(buffer_t const& is, size_t& pos, uint32_t& value);
103 void zipRead(buffer_t const& is, size_t& pos, uint16_t& value);
104 void zipRead(buffer_t const& is, size_t& pos, uint8_t& value);
105 void zipRead(buffer_t const& is, size_t& pos, buffer_t& buffer, ssize_t const count);
106 void zipRead(buffer_t const& is, size_t& pos, std::string& str, ssize_t const count);
107 
108 void zipWrite(std::ostream& os, uint32_t const& value);
109 void zipWrite(std::ostream& os, uint16_t const& value);
110 void zipWrite(std::ostream& os, uint8_t const& value);
111 void zipWrite(std::ostream& os, buffer_t const& buffer);
112 void zipWrite(std::ostream& os, std::string const& str);
113 
114 
115 } // zipios namespace
116 
117 // Local Variables:
118 // mode: cpp
119 // indent-tabs-mode: nil
120 // c-basic-offset: 4
121 // tab-width: 4
122 // End:
123 
124 // vim: ts=4 sw=4 et
125 #endif
void zipRead(std::istream &is, uint32_t &value)
void operator+=(std::vector< Type > &v1, std::vector< Type > const &v2)
Contatenate two vectors together.
void zipWrite(std::ostream &os, uint32_t const &value)
char const g_separator
The character used as the filename separator.
std::vector< unsigned char > buffer_t
A buffer of characters.
zipios configuration header.
std::ostringstream OutputStringStream
An output stream using strings.