]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Utility/StringLexer.h
MFV ntp-4.2.8p4 (r289715)
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Utility / StringLexer.h
1 //===--------------------- StringLexer.h -------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef utility_StringLexer_h_
11 #define utility_StringLexer_h_
12
13 #include <initializer_list>
14 #include <list>
15 #include <string>
16
17 namespace lldb_utility {
18     
19 class StringLexer
20 {
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
33     Peek ();
34     
35     bool
36     NextIf (Character c);
37     
38     std::pair<bool, Character>
39     NextIf (std::initializer_list<Character> cs);
40     
41     bool
42     AdvanceIf (const std::string& token);
43     
44     Character
45     Next ();
46     
47     bool
48     HasAtLeast (Size s);
49     
50     bool
51     HasAny (Character c);
52     
53     std::string
54     GetUnlexed ();
55     
56     // This will assert if there are less than s characters preceding the cursor.
57     void
58     PutBack (Size s);
59     
60     StringLexer&
61     operator = (const StringLexer& rhs);
62     
63 private:
64     std::string m_data;
65     Position m_position;
66     
67     void
68     Consume();
69 };
70
71 } // namespace lldb_private
72
73 #endif // #ifndef utility_StringLexer_h_