summaryrefslogtreecommitdiffstats
path: root/include/utils/Tokenizer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/utils/Tokenizer.h')
-rw-r--r--include/utils/Tokenizer.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/include/utils/Tokenizer.h b/include/utils/Tokenizer.h
index c7db5fb..bb25f37 100644
--- a/include/utils/Tokenizer.h
+++ b/include/utils/Tokenizer.h
@@ -28,7 +28,8 @@ namespace android {
* A simple tokenizer for loading and parsing ASCII text files line by line.
*/
class Tokenizer {
- Tokenizer(const String8& filename, FileMap* fileMap, char* buffer, size_t length);
+ Tokenizer(const String8& filename, FileMap* fileMap, char* buffer,
+ bool ownBuffer, size_t length);
public:
~Tokenizer();
@@ -42,6 +43,15 @@ public:
static status_t open(const String8& filename, Tokenizer** outTokenizer);
/**
+ * Prepares to tokenize the contents of a string.
+ *
+ * Returns NO_ERROR and a tokenizer for the string, if successful.
+ * Otherwise returns an error and sets outTokenizer to NULL.
+ */
+ static status_t fromContents(const String8& filename,
+ const char* contents, Tokenizer** outTokenizer);
+
+ /**
* Returns true if at the end of the file.
*/
inline bool isEof() const { return mCurrent == getEnd(); }
@@ -111,6 +121,7 @@ private:
String8 mFilename;
FileMap* mFileMap;
char* mBuffer;
+ bool mOwnBuffer;
size_t mLength;
const char* mCurrent;