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> 60 using Ptr = std::shared_ptr<Logger>;
70 [](
const std::string& msg){
71 std::cerr << msg << std::endl;
89 bool error(
const std::string& message,
const ax::ast::Node* node);
104 bool warning(
const std::string& message,
const ax::ast::Node* node);
109 inline size_t errors()
const {
return mNumErrors; }
111 inline size_t warnings()
const {
return mNumWarnings; }
114 inline bool hasError()
const {
return this->errors() > 0; }
116 inline bool hasWarning()
const {
return this->warnings() > 0; }
119 return this->getMaxErrors() > 0 && this->errors() >= this->getMaxErrors();
131 void setWarningsAsErrors(
const bool warnAsError =
false);
133 bool getWarningsAsErrors()
const;
140 void setMaxErrors(
const size_t maxErrors = 0);
142 size_t getMaxErrors()
const;
148 void setNumberedOutput(
const bool numbered =
true);
150 void setIndent(
const size_t ident = 0);
152 void setErrorPrefix(
const char* prefix =
"error: ");
154 void setWarningPrefix(
const char* prefix =
"warning: ");
158 void setPrintLines(
const bool print =
true);
161 bool getNumberedOutput()
const;
163 size_t getIndent()
const;
165 const char* getErrorPrefix()
const;
167 const char* getWarningPrefix()
const;
169 bool getPrintLines()
const;
174 void setSourceCode(
const char* code);
187 void setSourceTree(openvdb::ax::ast::Tree::ConstPtr tree);
200 friend class ::TestLogger;
208 std::unique_ptr<Settings> mSettings;
212 std::unique_ptr<SourceCode> mCode;
214 std::unordered_map<const ax::ast::Node*, CodeLocation> mNodeToLineColMap;
221 #endif // OPENVDB_AX_COMPILER_LOGGER_HAS_BEEN_INCLUDED std::pair< size_t, size_t > CodeLocation
Definition: Logger.h:62
std::shared_ptr< Logger > Ptr
Definition: Logger.h:60
OPENVDB_AX_API 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.
std::shared_ptr< const Tree > ConstPtr
Definition: AST.h:565
bool atErrorLimit() const
Returns true if it has errored and the max errors has been hit.
Definition: Logger.h:118
Definition: Exceptions.h:13
size_t warnings() const
Returns the number of warnings that have been encountered.
Definition: Logger.h:111
bool hasError() const
Returns true if an error has been found, false otherwise.
Definition: Logger.h:114
std::function< void(const std::string &)> OutputFunction
Definition: Logger.h:63
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:57
bool hasWarning() const
Returns true if a warning has been found, false otherwise.
Definition: Logger.h:116
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
The base abstract node which determines the interface and required methods for all derived concrete n...
Definition: AST.h:102
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218
size_t errors() const
Returns the number of errors that have been encountered.
Definition: Logger.h:109