1 //===--------------------- StringLexer.cpp -----------------------*- 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 #include "lldb/Utility/StringLexer.h"
15 using namespace lldb_utility;
17 StringLexer::StringLexer (std::string s) :
22 StringLexer::StringLexer (const StringLexer& rhs) :
24 m_position(rhs.m_position)
27 StringLexer::Character
30 return m_data[m_position];
34 StringLexer::NextIf (Character c)
45 std::pair<bool, StringLexer::Character>
46 StringLexer::NextIf (std::initializer_list<Character> cs)
61 StringLexer::AdvanceIf (const std::string& token)
63 auto pos = m_position;
81 StringLexer::Character
90 StringLexer::HasAtLeast (Size s)
92 return (m_data.size() - m_position) >= s;
96 StringLexer::PutBack (Size s)
98 assert (m_position >= s);
103 StringLexer::HasAny (Character c)
105 return m_data.find(c, m_position) != std::string::npos;
109 StringLexer::GetUnlexed ()
111 return std::string(m_data, m_position);
115 StringLexer::Consume()
121 StringLexer::operator = (const StringLexer& rhs)
126 m_position = rhs.m_position;