1 //===--------------------- StringLexer.h ------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef utility_StringLexer_h_
10 #define utility_StringLexer_h_
12 #include <initializer_list>
16 namespace lldb_utility {
20 typedef std::string::size_type Position;
21 typedef std::string::size_type Size;
23 typedef std::string::value_type Character;
25 StringLexer(std::string s);
27 // These APIs are not bounds-checked. Use HasAtLeast() if you're not sure.
30 bool NextIf(Character c);
32 std::pair<bool, Character> NextIf(std::initializer_list<Character> cs);
34 bool AdvanceIf(const std::string &token);
38 bool HasAtLeast(Size s);
40 std::string GetUnlexed();
42 // This will assert if there are less than s characters preceding the cursor.
45 StringLexer &operator=(const StringLexer &rhs);
54 } // namespace lldb_private
56 #endif // #ifndef utility_StringLexer_h_