// Parser.cpp #include #include #include #include #include "Parser.hpp" namespace NGBW { // Parser size_t Parser::FindFirstOf(char value, size_t offset) { assert(m_line); while (m_line[offset] != '\0') { if (m_line[offset] == value) return offset; offset += 1; } return std::string::npos; } size_t Parser::FindFirstNotSpace(size_t offset) { assert(m_line); while (m_line[offset] != '\0') { if (!std::isspace(m_line[offset])) return offset; offset += 1; } return std::string::npos; } size_t Parser::FindFirstSpace(size_t offset) { assert(m_line); while (m_line[offset] != '\0') { if (std::isspace(m_line[offset])) return offset; offset += 1; } return std::string::npos; } size_t Parser::FindLastNotSpace() { return FindLastNotSpace(std::strlen(m_line) - 1); } size_t Parser::FindLastNotSpace(size_t offset) { assert(m_line); int index = static_cast(offset); while (index >= 0) { if (!std::isspace(m_line[index])) return index; index -= 1; } return std::string::npos; } size_t Parser::FindFirstDigit(size_t offset) { assert(m_line); while (m_line[offset] != '\0') { if (std::isdigit(m_line[offset])) return offset; offset += 1; } return std::string::npos; } size_t Parser::FindFirstNotDigit(size_t offset) { assert(m_line); while (m_line[offset] != '\0') { if (!std::isdigit(m_line[offset])) return offset; offset += 1; } return std::string::npos; } } // namespace NGBW