1//------------------------------------------------------------------------------
2//	Copyright (c) 2001-2002, Haiku
3//
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:
10//
11//	The above copyright notice and this permission notice shall be included in
12//	all copies or substantial portions of the Software.
13//
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.
21//
22//	File Name:		RecentApps.cpp
23//	Author:			Tyler Dauwalder (tyler@dauwalder.net)
24//	Description:	Recently launched apps list
25//------------------------------------------------------------------------------
26/*!
27	\file sniffer/RosterSettingsCharStream.h
28	Character stream class
29*/
30#ifndef _ROSTER_SETTINGS_CHAR_STREAM_H
31#define _ROSTER_SETTINGS_CHAR_STREAM_H
32
33#include <sniffer/CharStream.h>
34#include <SupportDefs.h>
35
36#include <string>
37
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.
42
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
47	returned.
48
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
51	of a line.
52*/
53class RosterSettingsCharStream : public BPrivate::Storage::Sniffer::CharStream {
54public:
55	RosterSettingsCharStream(const std::string &string);
56	RosterSettingsCharStream();
57	virtual ~RosterSettingsCharStream();
58
59	status_t GetString(char *result);
60	status_t SkipLine();
61
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;
69private:
70	RosterSettingsCharStream(const RosterSettingsCharStream &ref);
71	RosterSettingsCharStream& operator=(const RosterSettingsCharStream &ref);
72};
73
74#endif // _ROSTER_SETTINGS_CHAR_STREAM_H
75