LLDB  mainline
StringLexer.h
Go to the documentation of this file.
1 //===-- StringLexer.h -------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_UTILITY_STRINGLEXER_H
10 #define LLDB_UTILITY_STRINGLEXER_H
11 
12 #include <initializer_list>
13 #include <string>
14 #include <utility>
15 
16 namespace lldb_private {
17 
18 class StringLexer {
19 public:
20  typedef std::string::size_type Position;
21  typedef std::string::size_type Size;
22 
23  typedef std::string::value_type Character;
24 
26 
27  // These APIs are not bounds-checked. Use HasAtLeast() if you're not sure.
28  Character Peek();
29 
30  bool NextIf(Character c);
31 
32  std::pair<bool, Character> NextIf(std::initializer_list<Character> cs);
33 
34  bool AdvanceIf(const std::string &token);
35 
36  Character Next();
37 
38  bool HasAtLeast(Size s);
39 
41 
42  // This will assert if there are less than s characters preceding the cursor.
43  void PutBack(Size s);
44 
45  StringLexer &operator=(const StringLexer &rhs);
46 
47 private:
50 
51  void Consume();
52 };
53 
54 } // namespace lldb_private
55 
56 #endif // LLDB_UTILITY_STRINGLEXER_H
lldb_private::StringLexer::Next
Character Next()
Definition: StringLexer.cpp:58
lldb_private::StringLexer::operator=
StringLexer & operator=(const StringLexer &rhs)
Definition: StringLexer.cpp:79
lldb_private::StringLexer::Consume
void Consume()
Definition: StringLexer.cpp:77
lldb_private::StringLexer::PutBack
void PutBack(Size s)
Definition: StringLexer.cpp:68
lldb_private::StringLexer::GetUnlexed
std::string GetUnlexed()
Definition: StringLexer.cpp:73
lldb_private::StringLexer::HasAtLeast
bool HasAtLeast(Size s)
Definition: StringLexer.cpp:64
lldb_private::StringLexer::NextIf
bool NextIf(Character c)
Definition: StringLexer.cpp:21
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::StringLexer::AdvanceIf
bool AdvanceIf(const std::string &token)
Definition: StringLexer.cpp:42
lldb_private::StringLexer::m_position
Position m_position
Definition: StringLexer.h:49
lldb_private::StringLexer::Character
std::string::value_type Character
Definition: StringLexer.h:23
lldb_private::StringLexer::StringLexer
StringLexer(std::string s)
Definition: StringLexer.cpp:17
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::StringLexer::m_data
std::string m_data
Definition: StringLexer.h:48
lldb_private::StringLexer::Size
std::string::size_type Size
Definition: StringLexer.h:21
lldb_private::StringLexer::Peek
Character Peek()
Definition: StringLexer.cpp:19
lldb_private::StringLexer
Definition: StringLexer.h:18
lldb_private::StringLexer::Position
std::string::size_type Position
Definition: StringLexer.h:20