15#ifndef WSFPARSEGRAMMAR_HPP
16#define WSFPARSEGRAMMAR_HPP
18#include "wsf_parser_export.h"
21#include "UtReferenceCount.hpp"
22#include "UtTextDocument.hpp"
44 : mObjectPtr(aObjectPtr)
47 if (mObjectPtr !=
nullptr)
49 mCountPtr =
new UtReferenceCount;
50 mCountPtr->AddStrongRef();
56 : mObjectPtr(aSrc.mObjectPtr)
57 , mCountPtr(aSrc.mCountPtr)
59 if (mCountPtr !=
nullptr)
61 mCountPtr->AddStrongRef();
79 mObjectPtr = aRhs.mObjectPtr;
80 mCountPtr = aRhs.mCountPtr;
82 if (mCountPtr !=
nullptr)
84 mCountPtr->AddStrongRef();
91 bool IsNull()
const {
return mObjectPtr ==
nullptr; }
104 if (mCountPtr && mCountPtr->IsValid())
112 if (mCountPtr && mCountPtr->IsValid())
114 if (mCountPtr->GetStrongCount() == 1)
120 mObjectPtr =
new T(*mObjectPtr);
121 mCountPtr =
new UtReferenceCount(1);
136 void ReleaseReference()
138 if (mCountPtr !=
nullptr)
140 if (mCountPtr->RemoveStrongRef())
143 mObjectPtr =
nullptr;
150 UtReferenceCount* mCountPtr;
221 if (!mWords.IsNull())
223 mWords.Write()->clear();
232 void Swap(
Expr& aRhs);
237 ExprList* wordList = mWords.Write();
238 wordList->push_back(
Expr());
239 aExp.
Swap(wordList->back());
244 mWords.Write()->push_back(aExp);
247 size_t WordCount()
const {
return mWords.IsNull() ? 0 : mWords.Read()->size(); }
248 const Expr& GetWord(
size_t aIndex)
const;
249 Expr& GetWord(
size_t aIndex);
254 return *mWords.Write();
256 const std::vector<Expr>&
words()
const
259 return *mWords.Read();
271 void NeedWords()
const;
272 using ExprList = std::vector<Expr>;
Definition WsfParseGrammar.hpp:31
UtSharablePointer< T > & operator=(const UtSharablePointer< T > &aRhs)
Definition WsfParseGrammar.hpp:74
~UtSharablePointer()
Definition WsfParseGrammar.hpp:67
UtSharablePointer()
Definition WsfParseGrammar.hpp:35
void Swap(UtSharablePointer< T > &aRhs)
Definition WsfParseGrammar.hpp:127
bool operator!=(const UtSharablePointer< T > &aRHS) const
Returns false if both point to the same object.
Definition WsfParseGrammar.hpp:97
const T * Read()
Definition WsfParseGrammar.hpp:102
T * Write()
Definition WsfParseGrammar.hpp:110
bool operator<(const UtSharablePointer< T > &aRHS) const
Provides strict weak ordering based on what the UtSharedPtr is referencing.
Definition WsfParseGrammar.hpp:100
UtSharablePointer(const UtSharablePointer< T > &aSrc)
Create a copy of shared object pointer.
Definition WsfParseGrammar.hpp:55
bool operator==(const UtSharablePointer< T > &aRHS) const
Returns true if both point to the same object.
Definition WsfParseGrammar.hpp:94
UtSharablePointer(T *aObjectPtr)
Definition WsfParseGrammar.hpp:43
bool IsNull() const
Return 'true' if the pointer to the object is null.
Definition WsfParseGrammar.hpp:91
Definition WsfParseGrammar.hpp:202
void Clear()
Definition WsfParseGrammar.hpp:219
Expr & operator=(const Expr &aRhs)
Definition WsfParseGrammar.cpp:31
std::vector< Expr > & words()
Definition WsfParseGrammar.hpp:251
void Swap(Expr &aRhs)
Definition WsfParseGrammar.cpp:21
std::string mLabel
Definition WsfParseGrammar.hpp:265
int mFlags
Definition WsfParseGrammar.hpp:276
std::string mType
Definition WsfParseGrammar.hpp:263
Expr & operator+=(const Expr &aExp)
Definition WsfParseGrammar.hpp:241
size_t WordCount() const
Definition WsfParseGrammar.hpp:247
static Expr Literal(const std::string &aText)
Definition WsfParseGrammar.hpp:212
Expr()
Definition WsfParseGrammar.hpp:204
void PushMove(Expr &aExp)
Definition WsfParseGrammar.hpp:234
const std::vector< Expr > & words() const
Definition WsfParseGrammar.hpp:256
std::string mText
Definition WsfParseGrammar.hpp:268
void SetLiteral(const std::string &aLiteral)
Definition WsfParseGrammar.hpp:226
RuleType mRuleType
Definition WsfParseGrammar.hpp:261
Definition WsfParseNode.hpp:61
Definition WsfParser.hpp:36
Definition WsfParseGrammar.cpp:20
RuleType
Definition WsfParseGrammar.hpp:171
@ cRT_ACTION_CALL
Definition WsfParseGrammar.hpp:179
@ cRT_ALTERNATE
Definition WsfParseGrammar.hpp:173
@ cRT_LITERAL
Definition WsfParseGrammar.hpp:176
@ cRT_SEQUENCE
Definition WsfParseGrammar.hpp:172
@ cRT_ROOT
Definition WsfParseGrammar.hpp:177
@ cRT_ACTION
Definition WsfParseGrammar.hpp:178
@ cRT_EXPRESSION
Definition WsfParseGrammar.hpp:175
Flags
Definition WsfParseGrammar.hpp:183
@ cRF_RECURRENCE_QUESTION
Definition WsfParseGrammar.hpp:186
@ cRF_RECURRENCE_PLUS
Definition WsfParseGrammar.hpp:185
@ cRF_RECURRENCE_STAR
Definition WsfParseGrammar.hpp:184
Definition WsfParseGrammar.cpp:18
Template specialization for wsf::comm::Address. Allows usage of Address in std::unordered_map/set.
Definition WsfCommAddress.hpp:185
void swap(WsfRoute &aLhs, WsfRoute &aRhs)
Definition WsfRoute.hpp:294