1 //===--------------------- StringLexer.h -------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef utility_StringLexer_h_
12 #define utility_StringLexer_h_
14 #include <initializer_list> // for initializer_list
15 #include <string> // for string
16 #include <utility> // for pair
18 namespace lldb_utility {
22 typedef std::string::size_type Position;
23 typedef std::string::size_type Size;
25 typedef std::string::value_type Character;
27 StringLexer(std::string s);
29 StringLexer(const StringLexer &rhs);
31 // These APIs are not bounds-checked. Use HasAtLeast() if you're not sure.
34 bool NextIf(Character c);
36 std::pair<bool, Character> NextIf(std::initializer_list<Character> cs);
38 bool AdvanceIf(const std::string &token);
42 bool HasAtLeast(Size s);
44 std::string GetUnlexed();
46 // This will assert if there are less than s characters preceding the cursor.
49 StringLexer &operator=(const StringLexer &rhs);
58 } // namespace lldb_private
60 #endif // #ifndef utility_StringLexer_h_