Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: base/big_endian.h

Issue 427153002: Add unsigned 64-bit integer support to BigEndianReader and BigEndianWriter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/big_endian.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_BIG_ENDIAN_H_ 5 #ifndef BASE_BIG_ENDIAN_H_
6 #define BASE_BIG_ENDIAN_H_ 6 #define BASE_BIG_ENDIAN_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const char* ptr() const { return ptr_; } 56 const char* ptr() const { return ptr_; }
57 int remaining() const { return end_ - ptr_; } 57 int remaining() const { return end_ - ptr_; }
58 58
59 bool Skip(size_t len); 59 bool Skip(size_t len);
60 bool ReadBytes(void* out, size_t len); 60 bool ReadBytes(void* out, size_t len);
61 // Creates a StringPiece in |out| that points to the underlying buffer. 61 // Creates a StringPiece in |out| that points to the underlying buffer.
62 bool ReadPiece(base::StringPiece* out, size_t len); 62 bool ReadPiece(base::StringPiece* out, size_t len);
63 bool ReadU8(uint8* value); 63 bool ReadU8(uint8* value);
64 bool ReadU16(uint16* value); 64 bool ReadU16(uint16* value);
65 bool ReadU32(uint32* value); 65 bool ReadU32(uint32* value);
66 bool ReadU64(uint64* value);
66 67
67 private: 68 private:
68 // Hidden to promote type safety. 69 // Hidden to promote type safety.
69 template<typename T> 70 template<typename T>
70 bool Read(T* v); 71 bool Read(T* v);
71 72
72 const char* ptr_; 73 const char* ptr_;
73 const char* end_; 74 const char* end_;
74 }; 75 };
75 76
76 // Allows writing integers in network order (big endian) while iterating over 77 // Allows writing integers in network order (big endian) while iterating over
77 // an underlying buffer. All the writing functions advance the internal pointer. 78 // an underlying buffer. All the writing functions advance the internal pointer.
78 class BASE_EXPORT BigEndianWriter { 79 class BASE_EXPORT BigEndianWriter {
79 public: 80 public:
80 BigEndianWriter(char* buf, size_t len); 81 BigEndianWriter(char* buf, size_t len);
81 82
82 char* ptr() const { return ptr_; } 83 char* ptr() const { return ptr_; }
83 int remaining() const { return end_ - ptr_; } 84 int remaining() const { return end_ - ptr_; }
84 85
85 bool Skip(size_t len); 86 bool Skip(size_t len);
86 bool WriteBytes(const void* buf, size_t len); 87 bool WriteBytes(const void* buf, size_t len);
87 bool WriteU8(uint8 value); 88 bool WriteU8(uint8 value);
88 bool WriteU16(uint16 value); 89 bool WriteU16(uint16 value);
89 bool WriteU32(uint32 value); 90 bool WriteU32(uint32 value);
91 bool WriteU64(uint64 value);
90 92
91 private: 93 private:
92 // Hidden to promote type safety. 94 // Hidden to promote type safety.
93 template<typename T> 95 template<typename T>
94 bool Write(T v); 96 bool Write(T v);
95 97
96 char* ptr_; 98 char* ptr_;
97 char* end_; 99 char* end_;
98 }; 100 };
99 101
100 } // namespace base 102 } // namespace base
101 103
102 #endif // BASE_BIG_ENDIAN_H_ 104 #endif // BASE_BIG_ENDIAN_H_
OLDNEW
« no previous file with comments | « no previous file | base/big_endian.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698