]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Utility/StringLexer.h
Upgrade Unbound to 1.6.8. More to follow.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Utility / StringLexer.h
1 //===--------------------- StringLexer.h -------------------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef utility_StringLexer_h_
12 #define utility_StringLexer_h_
13
14 #include <initializer_list> // for initializer_list
15 #include <string>           // for string
16 #include <utility>          // for pair
17
18 namespace lldb_utility {
19
20 class StringLexer {
21 public:
22   typedef std::string::size_type Position;
23   typedef std::string::size_type Size;
24
25   typedef std::string::value_type Character;
26
27   StringLexer(std::string s);
28
29   StringLexer(const StringLexer &rhs);
30
31   // These APIs are not bounds-checked.  Use HasAtLeast() if you're not sure.
32   Character Peek();
33
34   bool NextIf(Character c);
35
36   std::pair<bool, Character> NextIf(std::initializer_list<Character> cs);
37
38   bool AdvanceIf(const std::string &token);
39
40   Character Next();
41
42   bool HasAtLeast(Size s);
43
44   std::string GetUnlexed();
45
46   // This will assert if there are less than s characters preceding the cursor.
47   void PutBack(Size s);
48
49   StringLexer &operator=(const StringLexer &rhs);
50
51 private:
52   std::string m_data;
53   Position m_position;
54
55   void Consume();
56 };
57
58 } // namespace lldb_private
59
60 #endif // #ifndef utility_StringLexer_h_