15#ifndef WSFPARSENODE_HPP
16#define WSFPARSENODE_HPP
18#include "wsf_parser_export.h"
24#include "UtMemoryPool.hpp"
25#include "UtStringRef.hpp"
26#include "UtTextDocument.hpp"
70 void DebugPrint(ut::log::MessageStream& aStream);
75 WsfParseNode* FindChildByType(
const std::string& aType)
const;
76 UtTextRange SubtreeRange(UtTextDocument* aSource);
77 UtTextDocumentRange SubtreeRange();
78 UtTextRange GetBoundingRange(UtTextDocument* aSource);
79 WsfParseNode* GetLeftmostValue(UtTextDocument* aSourcePtr);
80 WsfParseNode* GetRightmostValue(UtTextDocument* aSourcePtr);
103 size_t LoadOrder()
const;
107 const UtTextDocumentRange& aRange,
108 const std::vector<WsfParseNode*>& aFileTransitionNodes,
109 std::vector<WsfParseNode*>& aNodes);
113 std::string GetTextValue();
115 void Print(std::ostream& aStream,
int aIndent,
bool aVerbose);
117 static std::string GetNodeString(
WsfParseNode* aNodePtr);
167 , mLexicalIndex(
ut::npos)
180 , mLexicalIndex(
ut::npos)
198 size_t mLexicalIndex;
205 UtMemoryPool* mAlloc;
208 class WSF_PARSER_EXPORT WsfParseNodeP :
public WsfParseNode
211 WsfParseNodeP(
WsfParseRule* aReader,
const char* aType, UtTextDocumentRange aValue = UtTextDocumentRange())
226 for (
size_t i = 0; i <
mAuxVals.size(); ++i)
236 mAlloc->DebugClear();
239 for (
size_t i = 0; i <
mAuxVals.size(); ++i)
255 void* memPtr = mAlloc->Alloc();
258 std::string ruleDescription =
"root-commands";
263 auto logger = ut::log::error() <<
"Memory allocation failed on parsing.";
264 logger.AddNote() <<
"Rule: " << ruleDescription;
265 logger.AddNote() <<
"File: " << aValue.mSource->GetFilePath().GetFileName();
266 throw std::bad_alloc();
268 return new (memPtr) WsfParseNodeP(aRule, aType, aValue);
274 void* memPtr = mAlloc->Alloc();
277 ut::log::error() <<
"Memory allocation failure.";
278 throw std::bad_alloc();
280 return new (memPtr) WsfParseNodeP();
@ cMDB_PARSE_NODE_POOL
Definition WsfParseDebugMarkers.hpp:30
std::vector< WsfParseNode * > WsfParseNodeList
Definition WsfParseNode.hpp:295
Abstract class for encapsulating auxiliary data to be attached to a parse node.
Definition WsfParseAuxData.hpp:19
@ cFILE_REFERENCE
Definition WsfParseAuxData.hpp:24
@ cDELAY_LOAD_DATA
Definition WsfParseAuxData.hpp:25
WsfParseAuxData(DataType aType)
Definition WsfParseAuxData.hpp:28
WsfParseDelayLoadData()
Definition WsfParseNode.hpp:48
size_t mLoadOrder
Definition WsfParseNode.hpp:53
UtStringRef mFilePath
Definition WsfParseNode.hpp:42
~WsfParseFileReferenceData() override=default
WsfParseFileReferenceData(const std::string &aFilePath)
Definition WsfParseNode.hpp:36
To improve efficiency, WsfParseNodePool handles the allocation and deletion of WsfParseNode's.
Definition WsfParseNode.hpp:204
UT_MEMORY_DEBUG_MARKER(cMDB_PARSE_NODE_POOL)
void SwapPool(WsfParseNodePool &aRhs)
Definition WsfParseNode.hpp:246
WsfParseNodePool(const WsfParseNodePool &)=default
WsfParseNode * NewNode(WsfParseRule *aRule, const char *aType, UtTextDocumentRange aValue=UtTextDocumentRange())
Create a new parse node.
Definition WsfParseNode.hpp:253
void AddAuxiliaryValue(WsfParseAuxData *aDataPtr)
Definition WsfParseNode.hpp:290
~WsfParseNodePool()
Definition WsfParseNode.hpp:223
void FreeNode(WsfParseNode *aNodePtr)
Definition WsfParseNode.hpp:283
std::vector< WsfParseAuxData * > mAuxVals
Definition WsfParseNode.hpp:291
WsfParseNodePool()
Definition WsfParseNode.hpp:222
void DeleteAllNodes()
Definition WsfParseNode.hpp:233
WsfParseNode * NewNode()
Create a new parse node.
Definition WsfParseNode.hpp:272
Definition WsfParseNode.hpp:61
friend class WsfParseNodeP
Definition WsfParseNode.hpp:64
WsfParseRule * mRulePtr
The WsfParseReader object which created this node.
Definition WsfParseNode.hpp:146
int GetFlags() const
Definition WsfParseNode.hpp:69
WsfParseNode * Down()
Definition WsfParseNode.hpp:99
void Add(WsfParseNode *aChild)
Definition WsfParseNode.cpp:24
friend class WsfParseNodePool
Definition WsfParseNode.hpp:63
Flags
Definition WsfParseNode.hpp:120
@ cLOAD_TYPE_NODE
Definition WsfParseNode.hpp:127
@ cPRUNE_NODE
Definition WsfParseNode.hpp:140
@ cSCRIPT_BLOCK
Definition WsfParseNode.hpp:132
@ cDELAY_LOAD
Definition WsfParseNode.hpp:136
@ cSCRIPT_FUNCTION
Definition WsfParseNode.hpp:133
@ cBLOCK_NODE
Definition WsfParseNode.hpp:131
@ cBLOCK_END
Definition WsfParseNode.hpp:138
@ cNAMED_NODE
Definition WsfParseNode.hpp:126
@ cSCRIPT_MASK
Definition WsfParseNode.hpp:135
@ cTYPE_MASK
Definition WsfParseNode.hpp:125
@ cLAZY_TYPE_REFERENCE_NODE
Definition WsfParseNode.hpp:128
@ cLAZY_TYPENAME_NODE
Definition WsfParseNode.hpp:129
@ cLAZY_TYPE_MASK
Definition WsfParseNode.hpp:130
@ cBLOCK_START
Definition WsfParseNode.hpp:137
@ cTYPE_NAME_NODE
Definition WsfParseNode.hpp:123
@ cERROR_INCOMPLETE
Flag indicates the node is the result of a partially matched rule.
Definition WsfParseNode.hpp:122
@ cTYPE_REFERENCE_NODE
Definition WsfParseNode.hpp:124
@ cSCRIPT_VARIABLES
Definition WsfParseNode.hpp:134
void SetFlags(int aMask)
Definition WsfParseNode.hpp:68
WsfParseNode * GetParent() const
Definition WsfParseNode.hpp:89
void MarkIncomplete()
Definition WsfParseNode.hpp:67
WsfParseNode()
Definition WsfParseNode.hpp:170
void SetAuxiliaryValue(WsfParseAuxData *aValuePtr)
Definition WsfParseNode.hpp:88
WsfParseNode(WsfParseRule *aReader, const char *aType, UtTextDocumentRange aValue=UtTextDocumentRange())
Definition WsfParseNode.hpp:157
WsfParseAuxData * mAuxiliaryValue
Definition WsfParseNode.hpp:150
void SetLexicalIndex(size_t aLexicalIndex)
Definition WsfParseNode.hpp:104
WsfParseNode * Left()
Definition WsfParseNode.hpp:97
const char * mType
Definition WsfParseNode.hpp:149
WsfParseNode * Right()
Definition WsfParseNode.hpp:95
int mFlags
Bit-set of flags for the node.
Definition WsfParseNode.hpp:143
WsfParseAuxData * GetAuxiliaryValue() const
Definition WsfParseNode.hpp:85
UtTextDocumentRange mValue
Definition WsfParseNode.hpp:154
WsfParseNode(const WsfParseNode &)=default
size_t LexicalIndex() const
Definition WsfParseNode.hpp:102
Definition WsfParseRule.hpp:131
virtual std::string GetRuleDescription()
Definition WsfParseRule.hpp:219
void swap(WsfRoute &aLhs, WsfRoute &aRhs)
Definition WsfRoute.hpp:294
Definition WsfSensorErrorModel.hpp:21