source: proiecte/HadoopJUnit/hadoop-0.20.1/src/c++/librecordio/binarchive.hh @ 141

Last change on this file since 141 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1/**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef BINARCHIVE_HH_
20#define BINARCHIVE_HH_
21
22#include "recordio.hh"
23
24namespace hadoop {
25
26class BinIndex : public Index {
27private:
28  size_t size;
29public:
30  BinIndex(size_t size_) { size = size_; }
31  bool done() { return (size==0); }
32  void incr() { size--; }
33  ~BinIndex() {}
34};
35 
36class IBinArchive : public IArchive {
37private:
38  InStream& stream;
39public:
40  IBinArchive(InStream& _stream) : stream(_stream) {}
41  virtual void deserialize(int8_t& t, const char* tag);
42  virtual void deserialize(bool& t, const char* tag);
43  virtual void deserialize(int32_t& t, const char* tag);
44  virtual void deserialize(int64_t& t, const char* tag);
45  virtual void deserialize(float& t, const char* tag);
46  virtual void deserialize(double& t, const char* tag);
47  virtual void deserialize(std::string& t, const char* tag);
48  virtual void deserialize(std::string& t, size_t& len, const char* tag);
49  virtual void startRecord(Record& s, const char* tag);
50  virtual void endRecord(Record& s, const char* tag);
51  virtual Index* startVector(const char* tag);
52  virtual void endVector(Index* idx, const char* tag);
53  virtual Index* startMap(const char* tag);
54  virtual void endMap(Index* idx, const char* tag);
55  virtual ~IBinArchive();
56};
57
58class OBinArchive : public OArchive {
59private:
60  OutStream& stream;
61public:
62  OBinArchive(OutStream& _stream) : stream(_stream) {}
63  virtual void serialize(int8_t t, const char* tag);
64  virtual void serialize(bool t, const char* tag);
65  virtual void serialize(int32_t t, const char* tag);
66  virtual void serialize(int64_t t, const char* tag);
67  virtual void serialize(float t, const char* tag);
68  virtual void serialize(double t, const char* tag);
69  virtual void serialize(const std::string& t, const char* tag);
70  virtual void serialize(const std::string& t, size_t len, const char* tag);
71  virtual void startRecord(const Record& s, const char* tag);
72  virtual void endRecord(const Record& s, const char* tag);
73  virtual void startVector(size_t len, const char* tag);
74  virtual void endVector(size_t len, const char* tag);
75  virtual void startMap(size_t len, const char* tag);
76  virtual void endMap(size_t len, const char* tag);
77  virtual ~OBinArchive();
78};
79
80}
81#endif /*BINARCHIVE_HH_*/
Note: See TracBrowser for help on using the repository browser.