diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcommon/llstreamtools.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llcommon/llstreamtools.h')
-rw-r--r-- | linden/indra/llcommon/llstreamtools.h | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llstreamtools.h b/linden/indra/llcommon/llstreamtools.h new file mode 100644 index 0000000..cd92911 --- /dev/null +++ b/linden/indra/llcommon/llstreamtools.h | |||
@@ -0,0 +1,117 @@ | |||
1 | /** | ||
2 | * @file llstreamtools.h | ||
3 | * @brief some helper functions for parsing legacy simstate and asset files. | ||
4 | * | ||
5 | * Copyright (c) 2005-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_STREAM_TOOLS_H | ||
29 | #define LL_STREAM_TOOLS_H | ||
30 | |||
31 | #include <iostream> | ||
32 | #include <string> | ||
33 | |||
34 | // unless specifed otherwise these all return input_stream.good() | ||
35 | |||
36 | // skips spaces and tabs | ||
37 | bool skip_whitespace(std::istream& input_stream); | ||
38 | |||
39 | // skips whitespace and newlines | ||
40 | bool skip_emptyspace(std::istream& input_stream); | ||
41 | |||
42 | // skips emptyspace and lines that start with a # | ||
43 | bool skip_comments_and_emptyspace(std::istream& input_stream); | ||
44 | |||
45 | // skips to character after next newline | ||
46 | bool skip_line(std::istream& input_stream); | ||
47 | |||
48 | // skips to beginning of next non-emptyspace | ||
49 | bool skip_to_next_word(std::istream& input_stream); | ||
50 | |||
51 | // skips to character after the end of next keyword | ||
52 | // a 'keyword' is defined as the first word on a line | ||
53 | bool skip_to_end_of_next_keyword(const char* keyword, std::istream& input_stream); | ||
54 | |||
55 | // skip_to_start_of_next_keyword() is disabled -- might tickle corruption bug | ||
56 | // in windows iostream | ||
57 | // skips to beginning of next keyword | ||
58 | // a 'keyword' is defined as the first word on a line | ||
59 | //bool skip_to_start_of_next_keyword(const char* keyword, std::istream& input_stream); | ||
60 | |||
61 | // characters are pulled out of input_stream and appended to output_string | ||
62 | bool get_word(std::string& output_string, std::istream& input_stream); | ||
63 | bool get_line(std::string& output_string, std::istream& input_stream); | ||
64 | |||
65 | // characters are pulled out of input_stream (up to a max of 'n') | ||
66 | // and appended to output_string | ||
67 | bool get_word(std::string& output_string, std::istream& input_stream, int n); | ||
68 | bool get_line(std::string& output_string, std::istream& input_stream, int n); | ||
69 | |||
70 | // unget_line() is disabled -- might tickle corruption bug in windows iostream | ||
71 | //// backs up the input_stream by line_size + 1 characters | ||
72 | //bool unget_line(const std::string& line, std::istream& input_stream); | ||
73 | |||
74 | // TODO -- move these string manipulator functions to a different file | ||
75 | |||
76 | // removes the last char in 'line' if it matches 'c' | ||
77 | // returns true if removed last char | ||
78 | bool remove_last_char(char c, std::string& line); | ||
79 | |||
80 | // replaces escaped characters with the correct characters from left to right | ||
81 | // "\\" ---> '\\' | ||
82 | // "\n" ---> '\n' | ||
83 | void unescape_string(std::string& line); | ||
84 | |||
85 | // replaces unescaped characters with expanded equivalents from left to right | ||
86 | // '\\' ---> "\\" | ||
87 | // '\n' ---> "\n" | ||
88 | void escape_string(std::string& line); | ||
89 | |||
90 | // replaces each '\n' character with ' ' | ||
91 | void replace_newlines_with_whitespace(std::string& line); | ||
92 | |||
93 | // returns 1 for solitary "{" | ||
94 | // returns -1 for solitary "}" | ||
95 | // otherwise returns 0 | ||
96 | int get_brace_count(const std::string& line); | ||
97 | |||
98 | // erases any double-quote characters in line | ||
99 | void remove_double_quotes(std::string& line); | ||
100 | |||
101 | // the 'keyword' is defined as the first word on a line | ||
102 | // the 'value' is everything after the keyword on the same line | ||
103 | // starting at the first non-whitespace and ending right before the newline | ||
104 | void get_keyword_and_value(std::string& keyword, | ||
105 | std::string& value, | ||
106 | const std::string& line); | ||
107 | |||
108 | // continue to read from the stream until you really can't | ||
109 | // read anymore or until we hit the count. Some istream | ||
110 | // implimentations have a max that they will read. | ||
111 | std::istream& fullread(std::istream& str, char *buf, std::streamsize requested); | ||
112 | |||
113 | std::istream& operator>>(std::istream& str, const char *tocheck); | ||
114 | |||
115 | #endif | ||
116 | |||
117 | |||