Tide 0.1.0
|
00001 /* Tide 00002 * 00003 * Variable-length integer header file. 00004 * 00005 * Copyright 2011 Geoffrey Biggs geoffrey.biggs@aist.go.jp 00006 * RT-Synthesis Research Group 00007 * Intelligent Systems Research Institute, 00008 * National Institute of Advanced Industrial Science and Technology (AIST), 00009 * Japan 00010 * All rights reserved. 00011 * 00012 * This file is part of Tide. 00013 * 00014 * Tide is free software; you can redistribute it and/or modify it under 00015 * the terms of the GNU Lesser General Public License as published by 00016 * the Free Software Foundation; either version 2.1 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * Tide is distributed in the hope that it will be useful, but WITHOUT 00020 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00021 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00022 * License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public 00025 * License along with Tide. If not, see <http://www.gnu.org/licenses/>. 00026 */ 00027 00028 #if !defined(TIDE_VINT_H_) 00029 #define TIDE_VINT_H_ 00030 00031 #include <cstddef> 00032 #include <istream> 00033 #include <ostream> 00034 #include <stdint.h> 00035 #include <utility> 00036 #include <vector> 00037 00040 00041 namespace tide 00042 { 00056 namespace vint 00057 { 00069 std::streamsize size(uint64_t integer); 00070 00077 typedef std::pair<uint64_t, std::streamsize> OffsetInt; 00092 OffsetInt s_to_u(int64_t integer); 00093 00108 int64_t u_to_s(OffsetInt integer); 00109 00131 std::vector<char> encode(uint64_t integer, std::streamsize req_size=0); 00132 00137 typedef std::pair<uint64_t, std::vector<char>::const_iterator> DecodeResult; 00138 00151 DecodeResult decode(std::vector<char> const& buffer); 00152 00172 std::streamsize write(uint64_t integer, std::ostream& output, 00173 std::streamsize req_size=0); 00174 00178 typedef std::pair<uint64_t, std::streamsize> ReadResult; 00179 00193 ReadResult read(std::istream& input); 00194 }; // namespace vint 00195 }; // namespace tide 00196 00198 // group utilities 00199 00200 #endif // TIDE_VINT_H_ 00201