Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
etorth committed Nov 20, 2024
1 parent 1d5e32b commit 5c20b3d
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions client/src/xmlf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

bool xmlf::checkTextLeaf(const tinyxml2::XMLNode *node)
{
if(!node){
throw fflerror("invalid argument: nullptr");
}
fflassert(node);

if(!node->NoChildren()){
return false;
Expand All @@ -20,9 +18,7 @@ bool xmlf::checkTextLeaf(const tinyxml2::XMLNode *node)

bool xmlf::checkEmojiLeaf(const tinyxml2::XMLNode *node)
{
if(!node){
throw fflerror("invalid argument: nullptr");
}
fflassert(node);

if(!node->NoChildren()){
return false;
Expand All @@ -49,9 +45,7 @@ bool xmlf::checkEmojiLeaf(const tinyxml2::XMLNode *node)

bool xmlf::checkImageLeaf(const tinyxml2::XMLNode *node)
{
if(!node){
throw fflerror("invalid argument: nullptr");
}
fflassert(node);

if(!node->NoChildren()){
return false;
Expand All @@ -78,9 +72,7 @@ bool xmlf::checkImageLeaf(const tinyxml2::XMLNode *node)

bool xmlf::checkValidLeaf(const tinyxml2::XMLNode *node)
{
if(!node){
throw fflerror("invalid argument: nullptr");
}
fflassert(node);

if(!node->NoChildren()){
throw fflerror("invalid argument: not a leaf");
Expand All @@ -91,9 +83,7 @@ bool xmlf::checkValidLeaf(const tinyxml2::XMLNode *node)

const char *xmlf::findAttribute(const tinyxml2::XMLNode *node, const char *attributeName, bool recursive)
{
if(!node){
throw fflerror("invalid argument: (nullptr)");
}
fflassert(node);

for(; node; node = node->Parent()){
if(auto element = node->ToElement()){
Expand All @@ -112,9 +102,7 @@ const char *xmlf::findAttribute(const tinyxml2::XMLNode *node, const char *attri

tinyxml2::XMLNode *xmlf::getNextLeaf(tinyxml2::XMLNode *node)
{
if(!node){
throw fflerror("invalid argument: (nullptr)");
}
fflassert(node);

if(!node->NoChildren()){
throw fflerror("invalid argument: [%p] is not a leaf node", to_cvptr(node));
Expand All @@ -134,9 +122,7 @@ tinyxml2::XMLNode *xmlf::getNextLeaf(tinyxml2::XMLNode *node)

tinyxml2::XMLNode *xmlf::getNodeFirstLeaf(tinyxml2::XMLNode *node)
{
if(!node){
throw fflerror("invalid argument: (nullptr)");
}
fflassert(node);

while(!node->NoChildren()){
node = node->FirstChild();
Expand All @@ -146,17 +132,13 @@ tinyxml2::XMLNode *xmlf::getNodeFirstLeaf(tinyxml2::XMLNode *node)

tinyxml2::XMLNode *xmlf::getTreeFirstLeaf(tinyxml2::XMLNode *node)
{
if(!node){
throw fflerror("invalid argument: (nullptr)");
}
fflassert(node);
return getNodeFirstLeaf(node->GetDocument()->FirstChild());
}

tinyxml2::XMLNode *xmlf::getNodeLastLeaf(tinyxml2::XMLNode *node)
{
if(!node){
throw fflerror("invalid argument: (nullptr)");
}
fflassert(node);

while(!node->NoChildren()){
node = node->LastChild();
Expand All @@ -166,9 +148,7 @@ tinyxml2::XMLNode *xmlf::getNodeLastLeaf(tinyxml2::XMLNode *node)

tinyxml2::XMLNode *xmlf::getTreeLastLeaf(tinyxml2::XMLNode *node)
{
if(!node){
throw fflerror("invalid argument: (nullptr)");
}
fflassert(node);
return getNodeLastLeaf(node->GetDocument()->LastChild());
}

Expand Down

0 comments on commit 5c20b3d

Please sign in to comment.