Tawara  0.1.0
ebml_int.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, 2012, Geoffrey Biggs, geoffrey.biggs@aist.go.jp
5  * RT-Synthesis Research Group
6  * Intelligent Systems Research Institute,
7  * National Institute of Advanced Industrial Science and Technology (AIST),
8  * Japan
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * * Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * * Redistributions in binary form must reproduce the above
18  * copyright notice, this list of conditions and the following
19  * disclaimer in the documentation and/or other materials provided
20  * with the distribution.
21  * * Neither the name of Geoffrey Biggs nor AIST, nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #if !defined(TAWARA_EBML_INT_H_)
40 #define TAWARA_EBML_INT_H_
41 
42 #include <cstddef>
43 #include <istream>
44 #include <ostream>
45 #include <stdint.h>
46 #include <vector>
47 
48 namespace tawara
49 {
65  namespace ebml_int
66  {
76  std::streamsize size_u(uint64_t integer);
77 
87  std::streamsize size_s(int64_t integer);
88 
97  std::vector<char> encode_u(uint64_t integer);
98 
107  std::vector<char> encode_s(int64_t integer);
108 
120  std::streamsize write_u(uint64_t integer, std::ostream& output);
121 
133  std::streamsize write_s(int64_t integer, std::ostream& output);
134 
145  uint64_t decode_u(std::vector<char> const& buffer);
146 
157  int64_t decode_s(std::vector<char> const& buffer);
158 
170  uint64_t read_u(std::istream& input, std::streamsize n);
171 
183  int64_t read_s(std::istream& input, std::streamsize n);
184  }; // namespace ebml_int
185 }; // namespace tawara
186 
187 #endif // TAWARA_EBML_INT_H_
188 
189 
std::vector< char > encode_u(uint64_t integer)
Encode an unsigned integer into a buffer.
std::streamsize write_u(uint64_t integer, std::ostream &output)
Encode and write an unsigned integer into a byte stream.
uint64_t read_u(std::istream &input, std::streamsize n)
Read and decode an unsigned integer from a byte stream.
uint64_t decode_u(std::vector< char > const &buffer)
Decode an unsigned integer from a buffer.
std::streamsize write_s(int64_t integer, std::ostream &output)
Encode and write a signed integer into a byte stream.
std::vector< char > encode_s(int64_t integer)
Encode a signed integer into a buffer.
std::streamsize size_u(uint64_t integer)
Get the size of an unsigned integer after encoding.
int64_t read_s(std::istream &input, std::streamsize n)
Read and decode a signed integer from a byte stream.
std::streamsize size_s(int64_t integer)
Get the size of a signed integer after encoding.
int64_t decode_s(std::vector< char > const &buffer)
Decode a signed integer from a buffer.