1 //===--------------------- StringLexer.h ------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef utility_StringLexer_h_
11 #define utility_StringLexer_h_
13 #include <initializer_list>
17 namespace lldb_utility {
21 typedef std::string::size_type Position;
22 typedef std::string::size_type Size;
24 typedef std::string::value_type Character;
26 StringLexer(std::string s);
28 StringLexer(const StringLexer &rhs);
30 // These APIs are not bounds-checked. Use HasAtLeast() if you're not sure.
33 bool NextIf(Character c);
35 std::pair<bool, Character> NextIf(std::initializer_list<Character> cs);
37 bool AdvanceIf(const std::string &token);
41 bool HasAtLeast(Size s);
43 std::string GetUnlexed();
45 // This will assert if there are less than s characters preceding the cursor.
48 StringLexer &operator=(const StringLexer &rhs);
57 } // namespace lldb_private
59 #endif // #ifndef utility_StringLexer_h_