zipios  2.2.0
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-2019 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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25 
33 #include "zipios/zipios-config.hpp"
34 
35 #include <vector>
36 #include <sstream>
37 #include <stdint.h>
38 
39 #if defined( ZIPIOS_WINDOWS )
40 typedef int32_t ssize_t;
41 #endif
42 
43 
74 template<class Type>
75 void operator += (std::vector<Type>& v1, std::vector<Type> const& v2)
76 {
77  // make sure these are not the same vector or the insert()
78  // is not unlikely to fail badly; it is expected that the
79  // user does not try to duplicate an array...
80  if(&v1 != &v2)
81  {
82  v1.reserve(v1.size() + v2.size());
83  v1.insert(v1.end(), v2.begin(), v2.end());
84  }
85 }
86 
87 
88 namespace zipios
89 {
90 
91 
92 extern char const g_separator;
93 
94 
95 typedef std::ostringstream OutputStringStream;
96 
97 
98 typedef std::vector<unsigned char> buffer_t;
99 
100 
101 void zipRead(std::istream& is, uint32_t& value);
102 void zipRead(std::istream& is, uint16_t& value);
103 void zipRead(std::istream& is, uint8_t& value);
104 void zipRead(std::istream& is, buffer_t& buffer, ssize_t const count);
105 void zipRead(std::istream& is, std::string& str, ssize_t const count);
106 
107 void zipRead(buffer_t const& is, size_t& pos, uint32_t& value);
108 void zipRead(buffer_t const& is, size_t& pos, uint16_t& value);
109 void zipRead(buffer_t const& is, size_t& pos, uint8_t& value);
110 void zipRead(buffer_t const& is, size_t& pos, buffer_t& buffer, ssize_t const count);
111 void zipRead(buffer_t const& is, size_t& pos, std::string& str, ssize_t const count);
112 
113 void zipWrite(std::ostream& os, uint32_t const& value);
114 void zipWrite(std::ostream& os, uint16_t const& value);
115 void zipWrite(std::ostream& os, uint8_t const& value);
116 void zipWrite(std::ostream& os, buffer_t const& buffer);
117 void zipWrite(std::ostream& os, std::string const& str);
118 
119 
120 } // zipios namespace
121 
122 // Local Variables:
123 // mode: cpp
124 // indent-tabs-mode: nil
125 // c-basic-offset: 4
126 // tab-width: 4
127 // End:
128 
129 // vim: ts=4 sw=4 et
130 #endif
The zipios namespace includes the Zipios library definitions.
Definition: backbuffer.cpp:35
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.