bux API Reference 1.9.0
Static library of whatever are seen required in general purpose but not directly supported from Modern C++. Or whatever reusable originated from my side projects.
Loading...
Searching...
No Matches
ParserBase.cpp
Go to the documentation of this file.
1#include "ParserBase.h"
2//----------------------------------------------------------
3#include <format> // std::format()
4#include <ostream> // std::ostream
5
6namespace bux {
7
8//
9// Implement Classes
10//
11void C_ParserLogCount::log(E_LogLevel ll, const C_SourcePos &pos, std::string_view message)
12{
13 ++m_count.at(ll);
14 static constinit char const *const LELEL_NAMES[]{"Fatal","Error","Warn","Info","Verbose"};
15 println(std::format("{} {}: {}", toStr(pos), LELEL_NAMES[ll], message));
16}
17
18std::string C_ParserLogCount::toStr(const C_SourcePos &pos) const
19{
20 if (pos.m_Source.empty())
21 return std::format("({},{})", pos.m_Line, pos.m_Col);
22 else
23 return std::format("{}@({},{})", pos.m_Source, pos.m_Line, pos.m_Col);
24}
25
26void C_ParserOStreamCount::println(const std::string &line)
27{
28 m_out <<line <<'\n';
29}
30
31} //namespace bux
std::array< unsigned, 5 > m_count
Definition ParserBase.h:84
virtual void println(const std::string &line)=0
void log(E_LogLevel ll, const C_SourcePos &pos, std::string_view message)
virtual std::string toStr(const C_SourcePos &pos) const
THE common namespace of bux library.
Definition AtomiX.cpp:3
E_LogLevel
Definition LogLevel.h:9
unsigned m_Col
Definition LexBase.h:42
std::string_view m_Source
Definition LexBase.h:40
unsigned m_Line
Definition LexBase.h:41