00001 /* --------------------------------------------------------------------------- 00002 commonc++ - A C++ Common Class Library 00003 Copyright (C) 2005-2012 Mark A Lindner 00004 00005 This file is part of commonc++. 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public 00018 License along with this library; if not, write to the Free 00019 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 --------------------------------------------------------------------------- 00021 */ 00022 00023 #ifndef __ccxx_XDREncoder_hxx 00024 #define __ccxx_XDREncoder_hxx 00025 00026 #include <commonc++/DataWriter.h++> 00027 CCXX_FWD_DECL(Variant); 00028 00029 namespace ccxx { 00030 00038 class COMMONCPP_API XDREncoder 00039 { 00040 public: 00041 00047 XDREncoder(DataWriter &writer); 00048 00050 ~XDREncoder() throw(); 00051 00058 inline XDREncoder& encode(bool v) throw(IOException) 00059 { return(encode(static_cast<uint32_t>(v))); } 00060 00067 inline XDREncoder& encode(byte_t v) throw(IOException) 00068 { return(encode(static_cast<uint32_t>(v))); } 00069 00076 XDREncoder& encode(char v) throw(IOException) 00077 { return(encode(static_cast<int32_t>(v))); } 00078 00085 inline XDREncoder& encode(int16_t v) throw(IOException) 00086 { return(encode(static_cast<int32_t>(v))); } 00087 00094 inline XDREncoder& encode(uint16_t v) throw(IOException) 00095 { return(encode(static_cast<uint32_t>(v))); } 00096 00103 inline XDREncoder& encode(int32_t v) throw(IOException) 00104 { _writer << v; return(*this); } 00105 00112 inline XDREncoder& encode(uint32_t v) throw(IOException) 00113 { _writer << v; return(*this); } 00114 00121 inline XDREncoder& encode(const int64_t &v) throw(IOException) 00122 { _writer << v; return(*this); } 00123 00130 inline XDREncoder& encode(const uint64_t &v) throw(IOException) 00131 { _writer << v; return(*this); } 00132 00139 inline XDREncoder& encode(float v) throw(IOException) 00140 { _writer << v; return(*this); } 00141 00148 inline XDREncoder& encode(const double &v) throw(IOException) 00149 { _writer << v; return(*this); } 00150 00158 XDREncoder& encode(const char *s, size_t maxlen = 0) throw(IOException); 00159 00167 inline XDREncoder& encode(const String &s, size_t maxlen = 0) 00168 throw(IOException) 00169 { return(encode(s.c_str(), maxlen)); } 00170 00178 XDREncoder& encode(const byte_t *v, size_t len) throw(IOException); 00179 00186 XDREncoder& encode(const Variant &v) throw(IOException); 00187 00188 private: 00189 00190 DataWriter &_writer; 00191 }; 00192 00193 }; // namespace ccxx 00194 00195 #endif // __ccxx_XDREncoder_hxx 00196 00197 /* end of header file */
1.6.3