sources/network/bytestream.h

changeset 11
cffa2777d917
parent 9
e7a09ceb4505
child 13
09dcaeaa216b
equal deleted inserted replaced
10:3874575d924d 11:cffa2777d917
42 static bool sink; 42 static bool sink;
43 43
44 Bytestream (unsigned long length = 0x800); 44 Bytestream (unsigned long length = 0x800);
45 Bytestream (const unsigned char* data, unsigned long length); 45 Bytestream (const unsigned char* data, unsigned long length);
46 Bytestream (const Vector<unsigned char>& bytes); 46 Bytestream (const Vector<unsigned char>& bytes);
47 Bytestream (const Bytestream& other);
47 ~Bytestream(); 48 ~Bytestream();
48 49
49 inline METHOD allocated_size() const -> unsigned long; 50 inline METHOD allocated_size() const -> unsigned long;
50 inline METHOD bytes_left() const -> unsigned long; 51 inline METHOD bytes_left() const -> unsigned long;
51 METHOD clear() -> void; 52 METHOD clear() -> void;
60 METHOD read_string (bool* ok = &sink) -> String; 61 METHOD read_string (bool* ok = &sink) -> String;
61 METHOD read_float (bool* ok = &sink) -> float; 62 METHOD read_float (bool* ok = &sink) -> float;
62 METHOD resize (unsigned long length) -> void; 63 METHOD resize (unsigned long length) -> void;
63 inline METHOD rewind() -> void; 64 inline METHOD rewind() -> void;
64 inline METHOD seek (unsigned long pos) -> void; 65 inline METHOD seek (unsigned long pos) -> void;
66 inline METHOD to_vector() const -> Vector<unsigned char>;
65 METHOD write (const unsigned char* val, unsigned int length) -> void; 67 METHOD write (const unsigned char* val, unsigned int length) -> void;
66 METHOD write_buffer (const Bytestream& other) -> void; 68 METHOD write_buffer (const Bytestream& other) -> void;
67 METHOD write_buffer (const Vector<unsigned char>& other) -> void; 69 METHOD write_buffer (const Vector<unsigned char>& other) -> void;
68 METHOD write_byte (char val) -> void; 70 METHOD write_byte (char val) -> void;
69 METHOD write_double (double val) -> void; 71 METHOD write_double (double val) -> void;
73 METHOD write_string (const String& val) -> void; 75 METHOD write_string (const String& val) -> void;
74 inline METHOD written_length() const -> unsigned long; 76 inline METHOD written_length() const -> unsigned long;
75 77
76 inline METHOD operator[] (unsigned long idx) -> unsigned char&; 78 inline METHOD operator[] (unsigned long idx) -> unsigned char&;
77 inline METHOD operator[] (unsigned long idx) const -> unsigned char; 79 inline METHOD operator[] (unsigned long idx) const -> unsigned char;
80 METHOD operator= (const Bytestream& other) -> Bytestream&;
78 81
79 private: 82 private:
80 unsigned char* m_data; 83 unsigned char* m_data;
81 unsigned char* m_cursor; 84 unsigned char* m_cursor;
82 unsigned long m_allocatedSize; 85 unsigned long m_allocatedSize;
172 inline METHOD 175 inline METHOD
173 Bytestream::data() const -> const unsigned char* 176 Bytestream::data() const -> const unsigned char*
174 { 177 {
175 return m_data; 178 return m_data;
176 } 179 }
180
181 // -------------------------------------------------------------------------------------------------
182 //
183 inline METHOD
184 Bytestream::to_vector() const -> Vector<unsigned char>
185 {
186 return Vector<unsigned char> (m_data, m_writtenLength);
187 }

mercurial