1 //------------------------------------------------------------------------------
2 // Copyright (c) 2001-2002, OpenBeOS
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
22 // File Name: RecentApps.cpp
23 // Author: Tyler Dauwalder (tyler@dauwalder.net)
24 // Description: Recently launched apps list
25 //------------------------------------------------------------------------------
27 \file sniffer/RosterSettingsCharStream.h
28 Character stream class
30 #ifndef _ROSTER_SETTINGS_CHAR_STREAM_H
31 #define _ROSTER_SETTINGS_CHAR_STREAM_H
33 #include <sniffer/CharStream.h>
34 #include <SupportDefs.h>
38 //! A character stream manager designed for use with RosterSettings files
39 /*! The purpose for this class is to make reading through RosterSettings files,
40 which contain a number of different types of strings (some with escapes),
41 as well as comments, as painless as possible.
43 The main idea is that GetString() will return \c B_OK and a new string
44 until it hits an error or the end of the line, at which point an error
45 code is returned. The next call to GetString() starts the cycle over on
46 the next line. When the end of the stream is finally hit, kEndOfStream is
49 SkipLine() simply moves the position of the stream to the next line, and is
50 used when a valid string containing invalid data is discovered in the middle
53 class RosterSettingsCharStream
: public BPrivate::Storage::Sniffer::CharStream
{
55 RosterSettingsCharStream(const std::string
&string
);
56 RosterSettingsCharStream();
57 virtual ~RosterSettingsCharStream();
59 status_t
GetString(char *result
);
62 static const status_t kEndOfLine
= B_ERRORS_END
+1;
63 static const status_t kEndOfStream
= B_ERRORS_END
+2;
64 static const status_t kInvalidEscape
= B_ERRORS_END
+3;
65 static const status_t kUnterminatedQuotedString
= B_ERRORS_END
+4;
66 static const status_t kComment
= B_ERRORS_END
+5;
67 static const status_t kUnexpectedState
= B_ERRORS_END
+6;
68 static const status_t kStringTooLong
= B_ERRORS_END
+7;
70 RosterSettingsCharStream(const RosterSettingsCharStream
&ref
);
71 RosterSettingsCharStream
& operator=(const RosterSettingsCharStream
&ref
);
74 #endif // _ROSTER_SETTINGS_CHAR_STREAM_H