zipios 2.3.4
Zipios -- a small C++ library providing 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-2022 Made to Order Software Corp. All Rights Reserved
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
34
35#include <vector>
36#include <sstream>
37#include <cstdint>
38
39#if defined( ZIPIOS_WINDOWS )
40typedef int32_t ssize_t;
41#endif
42
43
74template<class Type>
75void 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
88namespace zipios
89{
90
91
92extern char const g_separator;
93
94
95typedef std::ostringstream OutputStringStream;
96
97
98typedef std::vector<unsigned char> buffer_t;
99
100
101void zipRead(std::istream & is, uint32_t & value);
102void zipRead(std::istream & is, uint16_t & value);
103void zipRead(std::istream & is, uint8_t & value);
104void zipRead(std::istream & is, buffer_t & buffer, ssize_t const count);
105void zipRead(std::istream & is, std::string & str, ssize_t const count);
106
107void zipRead(buffer_t const & is, size_t & pos, uint32_t & value);
108void zipRead(buffer_t const & is, size_t & pos, uint16_t & value);
109void zipRead(buffer_t const & is, size_t & pos, uint8_t & value);
110void zipRead(buffer_t const & is, size_t & pos, buffer_t & buffer, ssize_t const count);
111void zipRead(buffer_t const & is, size_t & pos, std::string & str, ssize_t const count);
112
113void zipWrite(std::ostream & os, uint32_t const & value);
114void zipWrite(std::ostream & os, uint16_t const & value);
115void zipWrite(std::ostream & os, uint8_t const & value);
116void zipWrite(std::ostream & os, buffer_t const & buffer);
117void 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.
void zipRead(std::istream &is, uint32_t &value)
std::vector< unsigned char > buffer_t
A buffer of characters.
char const g_separator
The character used as the filename separator.
void zipWrite(std::ostream &os, uint32_t const &value)
std::ostringstream OutputStringStream
An output stream using strings.
zipios configuration header.
void operator+=(std::vector< Type > &v1, std::vector< Type > const &v2)
Concatenate two vectors together.