Serializer.hh

00001 
00019 #ifndef avro_Serializer_hh__
00020 #define avro_Serializer_hh__
00021 
00022 #include <boost/noncopyable.hpp>
00023 
00024 #include "Writer.hh"
00025 #include "ValidatingWriter.hh"
00026 
00027 namespace avro {
00028 
00031 
00032 template<class Writer>
00033 class Serializer : private boost::noncopyable
00034 {
00035 
00036   public:
00037 
00039     explicit Serializer(OutputStreamer &out) :
00040         writer_(out)
00041     {}
00042 
00044     Serializer(const ValidSchema &schema, OutputStreamer &out) :
00045         writer_(schema, out)
00046     {}
00047 
00048     void writeNull() {
00049         writer_.writeValue(Null());
00050     }
00051 
00052     void writeBool(bool val) {
00053         writer_.writeValue(val);
00054     }
00055 
00056     void writeInt(int32_t val) {
00057         writer_.writeValue(val);
00058     }
00059 
00060     void writeLong(int64_t val) {
00061         writer_.writeValue(val);
00062     }
00063 
00064     void writeFloat(float val) {
00065         writer_.writeValue(val);
00066     }
00067 
00068     void writeDouble(double val) {
00069         writer_.writeValue(val);
00070     }
00071 
00072     void writeBytes(const void *val, size_t size) {
00073         writer_.writeBytes(val);
00074     }
00075 
00076     template <size_t N>
00077     void writeFixed(const uint8_t (&val)[N]) {
00078         writer_.writeFixed(val);
00079     }
00080 
00081     template <size_t N>
00082     void writeFixed(const boost::array<uint8_t, N> &val) {
00083         writer_.writeFixed(val);
00084     }
00085 
00086     void writeString(const std::string &val) {
00087         writer_.writeValue(val);
00088     }
00089 
00090     void writeRecord() {
00091         writer_.writeRecord();
00092     }
00093 
00094     void writeArrayBlock(int64_t size) {
00095         writer_.writeArrayBlock(size);
00096     }
00097 
00098     void writeArrayEnd() {
00099         writer_.writeArrayEnd();
00100     }
00101 
00102     void writeMapBlock(int64_t size) {
00103         writer_.writeMapBlock(size);
00104     }
00105 
00106     void writeMapEnd() {
00107         writer_.writeMapEnd();
00108     }
00109 
00110     void writeUnion(int64_t choice) {
00111         writer_.writeUnion(choice);
00112     }
00113 
00114     void writeEnum(int64_t choice) {
00115         writer_.writeEnum(choice);
00116     }
00117 
00118   private:
00119 
00120     Writer writer_;
00121 
00122 };
00123 
00124 } // namespace avro
00125 
00126 #endif
Generated on Mon Jun 7 02:59:20 2010 for Avro C++ by  doxygen 1.6.3