Go to the documentation of this file.
12 #ifndef OPENVDB_AX_COMPILER_LOGGER_HAS_BEEN_INCLUDED
13 #define OPENVDB_AX_COMPILER_LOGGER_HAS_BEEN_INCLUDED
15 #include "../ast/AST.h"
17 #include <openvdb/version.h>
21 #include <unordered_map>
57 using Ptr = std::shared_ptr<Logger>;
67 [](
const std::string& msg){
68 std::cerr << msg << std::endl;
70 const OutputFunction& warnings = [](
const std::string&){});
79 bool error(
const std::string& message,
const CodeLocation& lineCol = CodeLocation(0,0));
86 bool error(
const std::string& message,
const ax::ast::Node* node);
94 bool warning(
const std::string& message,
const CodeLocation& lineCol = CodeLocation(0,0));
101 bool warning(
const std::string& message,
const ax::ast::Node* node);
106 inline size_t errors()
const {
return mNumErrors; }
108 inline size_t warnings()
const {
return mNumWarnings; }
111 inline bool hasError()
const {
return this->errors() > 0; }
113 inline bool hasWarning()
const {
return this->warnings() > 0; }
116 return this->getMaxErrors() > 0 && this->errors() >= this->getMaxErrors();
128 void setWarningsAsErrors(
const bool warnAsError =
false);
130 bool getWarningsAsErrors()
const;
135 void setMaxErrors(
const size_t maxErrors = 0);
137 size_t getMaxErrors()
const;
143 void setNumberedOutput(
const bool numbered =
true);
145 void setIndent(
const size_t ident = 0);
147 void setErrorPrefix(
const char* prefix =
"error: ");
149 void setWarningPrefix(
const char* prefix =
"warning: ");
153 void setPrintLines(
const bool print =
true);
156 bool getNumberedOutput()
const;
158 size_t getIndent()
const;
160 const char* getErrorPrefix()
const;
162 const char* getWarningPrefix()
const;
164 bool getPrintLines()
const;
169 void setSourceCode(
const char* code);
182 void setSourceTree(openvdb::ax::ast::Tree::ConstPtr tree);
187 void addNodeLocation(
const ax::ast::Node* node,
const CodeLocation& location);
195 friend class ::TestLogger;
197 std::function<void(
const std::string&)> mErrorOutput;
198 std::function<void(
const std::string&)> mWarningOutput;
203 std::unique_ptr<Settings> mSettings;
207 std::unique_ptr<SourceCode> mCode;
209 std::unordered_map<const ax::ast::Node*, CodeLocation> mNodeToLineColMap;
216 #endif // OPENVDB_AX_COMPILER_LOGGER_HAS_BEEN_INCLUDED
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:178
void print(const ast::Node &node, const bool numberStatements=true, std::ostream &os=std::cout, const char *indent=" ")
Writes a descriptive printout of a Node hierarchy into a target stream.
bool hasWarning() const
Returns true if a warning has been found, false otherwise.
Definition: Logger.h:113
size_t errors() const
Returns the number of errors that have been encountered.
Definition: Logger.h:106
std::shared_ptr< const Tree > ConstPtr
Definition: AST.h:564
std::pair< size_t, size_t > CodeLocation
Definition: Logger.h:59
size_t warnings() const
Returns the number of warnings that have been encountered.
Definition: Logger.h:108
std::function< void(const std::string &)> OutputFunction
Definition: Logger.h:60
bool atErrorLimit() const
Returns true if it has errored and the max errors has been hit.
Definition: Logger.h:115
The base abstract node which determines the interface and required methods for all derived concrete n...
Definition: AST.h:101
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:54
std::shared_ptr< Logger > Ptr
Definition: Logger.h:57
bool hasError() const
Returns true if an error has been found, false otherwise.
Definition: Logger.h:111
Definition: openvdb/Exceptions.h:13