1/********************************************************************
2 * Copyright (c) 2013 - 2014, Pivotal Inc.
3 * All rights reserved.
4 *
5 * Author: Zhanwei Wang
6 ********************************************************************/
7/********************************************************************
8 * 2014 -
9 * open source under Apache License Version 2.0
10 ********************************************************************/
11/**
12 * Licensed to the Apache Software Foundation (ASF) under one
13 * or more contributor license agreements. See the NOTICE file
14 * distributed with this work for additional information
15 * regarding copyright ownership. The ASF licenses this file
16 * to you under the Apache License, Version 2.0 (the
17 * "License"); you may not use this file except in compliance
18 * with the License. You may obtain a copy of the License at
19 *
20 * http://www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 */
28#ifndef _HDFS_LIBHDFS_3_UTIL_WritableUtils_H_
29#define _HDFS_LIBHDFS_3_UTIL_WritableUtils_H_
30
31#include <string>
32
33namespace Hdfs {
34namespace Internal {
35
36class WritableUtils {
37public:
38 WritableUtils(char * b, size_t l);
39
40 int32_t ReadInt32();
41
42 int64_t ReadInt64();
43
44 void ReadRaw(char * buf, size_t size);
45
46 std::string ReadText();
47
48 int readByte();
49
50 size_t WriteInt32(int32_t value);
51
52 size_t WriteInt64(int64_t value);
53
54 size_t WriteRaw(const char * buf, size_t size);
55
56 size_t WriteText(const std::string & str);
57
58private:
59 int decodeWritableUtilsSize(int value);
60
61 void writeByte(int val);
62
63 bool isNegativeWritableUtils(int value);
64
65 int32_t ReadBigEndian32();
66
67private:
68 char * buffer;
69 size_t len;
70 size_t current;
71};
72
73}
74}
75#endif /* _HDFS_LIBHDFS_3_UTIL_WritableUtils_H_ */
76