1 //---------------------------------------------------------------------- 2 // This software is part of the Haiku distribution and is covered 3 // by the MIT License. 4 //--------------------------------------------------------------------- 5 /*! 6 \file sniffer/CharStream.h 7 Character stream class 8 */ 9 #ifndef _SNIFFER_CHAR_STREAM_H 10 #define _SNIFFER_CHAR_STREAM_H 11 12 #include <SupportDefs.h> 13 14 #include <string> 15 16 namespace BPrivate { 17 namespace Storage { 18 namespace Sniffer { 19 20 //! Manages a stream of characters 21 /*! CharStream is used by the scanner portion of the parser, which is implemented 22 in TokenStream::SetTo(). 23 24 It's also used by BPrivate::TRoster while parsing through the the 25 roster's RosterSettings file. 26 */ 27 class CharStream { 28 public: 29 CharStream(const std::string &string); 30 CharStream(); 31 virtual ~CharStream(); 32 33 status_t SetTo(const std::string &string); 34 void Unset(); 35 status_t InitCheck() const; 36 bool IsEmpty() const; 37 size_t Pos() const; 38 const std::string& String() const; 39 40 char Get(); 41 void Unget(); 42 43 private: 44 std::string fString; 45 size_t fPos; 46 status_t fCStatus; 47 48 CharStream(const CharStream &ref); 49 CharStream& operator=(const CharStream &ref); 50 }; 51 52 }; // namespace Sniffer 53 }; // namespace Storage 54 }; // namespace BPrivate 55 56 #endif // _SNIFFER_CHAR_STREAM_H 57