12 #ifndef OPENVDB_AX_COMPILER_LOGGER_HAS_BEEN_INCLUDED 13 #define OPENVDB_AX_COMPILER_LOGGER_HAS_BEEN_INCLUDED 15 #include "../ast/AST.h" 21 #include <unordered_map> 57 using Ptr = std::shared_ptr<Logger>;
67 [](
const std::string& msg){
68 std::cerr << msg << std::endl;
78 bool error(
const std::string& message,
const CodeLocation& lineCol);
85 bool error(
const std::string& message,
const ax::ast::Node* node);
91 bool warning(
const std::string& message,
const CodeLocation& lineCol);
98 bool warning(
const std::string& message,
const ax::ast::Node* node);
103 inline size_t errors()
const {
return mNumErrors; }
105 inline size_t warnings()
const {
return mNumWarnings; }
108 inline bool hasError()
const {
return this->errors() > 0; }
110 inline bool hasWarning()
const {
return this->warnings() > 0; }
113 return this->getMaxErrors() > 0 && this->errors() >= this->getMaxErrors();
125 void setWarningsAsErrors(
const bool warnAsError =
false);
127 bool getWarningsAsErrors()
const;
132 void setMaxErrors(
const size_t maxErrors = 0);
134 size_t getMaxErrors()
const;
140 void setNumberedOutput(
const bool numbered =
true);
142 void setErrorPrefix(
const char* prefix =
"error: ");
144 void setWarningPrefix(
const char* prefix =
"warning: ");
148 void setPrintLines(
const bool print =
true);
151 bool getNumberedOutput()
const;
153 const char* getErrorPrefix()
const;
155 const char* getWarningPrefix()
const;
157 bool getPrintLines()
const;
162 void setSourceCode(
const char* code);
175 void setSourceTree(openvdb::ax::ast::Tree::ConstPtr tree);
188 friend class ::TestLogger;
190 std::function<void(const std::string&)> mErrorOutput;
191 std::function<void(const std::string&)> mWarningOutput;
196 std::unique_ptr<Settings> mSettings;
200 std::unique_ptr<SourceCode> mCode;
202 std::unordered_map<const ax::ast::Node*, CodeLocation> mNodeToLineColMap;
209 #endif // OPENVDB_AX_COMPILER_LOGGER_HAS_BEEN_INCLUDED std::pair< size_t, size_t > CodeLocation
Definition: Logger.h:59
bool hasWarning() const
Returns true if a warning has been found, false otherwise.
Definition: Logger.h:110
std::shared_ptr< const Tree > ConstPtr
Definition: AST.h:564
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:94
Definition: openvdb/Exceptions.h:13
The base abstract node which determines the interface and required methods for all derived concrete n...
Definition: AST.h:101
bool hasError() const
Returns true if an error has been found, false otherwise.
Definition: Logger.h:108
std::function< void(const std::string &)> OutputFunction
Definition: Logger.h:60
Library and file format version numbers.
size_t warnings() const
Returns the number of warnings that have been encountered.
Definition: Logger.h:105
bool atErrorLimit() const
Returns true if it has errored and the max errors has been hit.
Definition: Logger.h:112
std::shared_ptr< Logger > Ptr
Definition: Logger.h:57
size_t errors() const
Returns the number of errors that have been encountered.
Definition: Logger.h:103
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:146
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.
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:54