From eb92c904c62dad767dc680c8bfb938d37b0dac49 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Sat, 12 Jul 2014 11:45:47 -0600 Subject: [PATCH] split Tokenizer into its own header --- include/avian/util/string.h | 32 -------------------- include/avian/util/tokenizer.h | 54 ++++++++++++++++++++++++++++++++++ src/avian/classpath-common.h | 1 + src/finder.cpp | 1 + 4 files changed, 56 insertions(+), 32 deletions(-) create mode 100644 include/avian/util/tokenizer.h diff --git a/include/avian/util/string.h b/include/avian/util/string.h index 704dd9a5b1..49d854ab67 100644 --- a/include/avian/util/string.h +++ b/include/avian/util/string.h @@ -30,38 +30,6 @@ class String { } }; -class Tokenizer { - public: - Tokenizer(const char* s, char delimiter) - : s(s), limit(0), delimiter(delimiter) - { - } - - Tokenizer(String str, char delimiter) - : s(str.text), limit(str.text + str.length), delimiter(delimiter) - { - } - - bool hasMore() - { - while (s != limit and *s == delimiter) - ++s; - return s != limit and *s != 0; - } - - String next() - { - const char* p = s; - while (s != limit and *s and *s != delimiter) - ++s; - return String(p, s - p); - } - - const char* s; - const char* limit; - char delimiter; -}; - } // namespace util } // namespace avain diff --git a/include/avian/util/tokenizer.h b/include/avian/util/tokenizer.h new file mode 100644 index 0000000000..5da035bac8 --- /dev/null +++ b/include/avian/util/tokenizer.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2008-2014, Avian Contributors + + Permission to use, copy, modify, and/or distribute this software + for any purpose with or without fee is hereby granted, provided + that the above copyright notice and this permission notice appear + in all copies. + + There is NO WARRANTY for this software. See license.txt for + details. */ + +#ifndef AVIAN_UTIL_TOKENIZER_H +#define AVIAN_UTIL_TOKENIZER_H + +#include "string.h" + +namespace avian { +namespace util { + +class Tokenizer { + public: + Tokenizer(const char* s, char delimiter) + : s(s), limit(0), delimiter(delimiter) + { + } + + Tokenizer(String str, char delimiter) + : s(str.text), limit(str.text + str.length), delimiter(delimiter) + { + } + + bool hasMore() + { + while (s != limit and *s == delimiter) + ++s; + return s != limit and *s != 0; + } + + String next() + { + const char* p = s; + while (s != limit and *s and *s != delimiter) + ++s; + return String(p, s - p); + } + + const char* s; + const char* limit; + char delimiter; +}; + +} // namespace util +} // namespace avain + +#endif // AVIAN_UTIL_TOKENIZER_H diff --git a/src/avian/classpath-common.h b/src/avian/classpath-common.h index 83d62d6eae..8c915c3a83 100644 --- a/src/avian/classpath-common.h +++ b/src/avian/classpath-common.h @@ -13,6 +13,7 @@ #include #include +#include using namespace avian::util; diff --git a/src/finder.cpp b/src/finder.cpp index f211928663..28ea5bd14d 100644 --- a/src/finder.cpp +++ b/src/finder.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include "avian/zlib-custom.h" #include "avian/finder.h"