Files
xtree.old.ng/src/model/xqnode.cpp

93 lines
2.2 KiB
C++
Raw Normal View History

2025-08-05 22:39:41 +02:00
/***************************************************************************
source::worx xtree
Copyright © 2024-2025 c.holzheuer
christoph.holzheuer@gmail.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
***************************************************************************/
#include <xqnode.h>
#include <xqitem.h>
2025-08-07 10:39:42 +02:00
2025-08-11 22:55:32 +02:00
//! hilfsfunktion: gibt diesen teilbaum rekursiv aus
2025-08-07 10:39:42 +02:00
2025-08-05 22:39:41 +02:00
void inspect( const XQNodePtr& node, int indent )
{
qDebug() << std::string(indent * 2, ' ').c_str() << node.use_count() << ": " << node->to_string();
if (node->has_children())
{
for (const auto& child : node->children())
{
inspect( child, indent + 1 );
}
}
}
2025-08-11 22:55:32 +02:00
//! operator<< für QString und std::ostream
2025-08-07 10:39:42 +02:00
2025-08-05 22:39:41 +02:00
// Overload the operator<< for MyClass and std::ostream
std::ostream& operator<<(std::ostream& os, const QString& obj)
{
// Simply call the getter and insert the string into the stream
os << obj.toStdString();
return os; // Return the stream for chaining
}
2025-08-11 22:55:32 +02:00
//! 'QString' implementation von split
2025-08-05 22:39:41 +02:00
template<>
bool znode::zpayload<QString>::xstr_split_by(const QString& entry, const QString& sep, QString& key, QString& value )
{
int index = entry.indexOf(sep);
if(index < 0)
return false;
key = entry.left(index);
value = entry.mid( index+sep.length() );
return true;
}
2025-08-07 10:39:42 +02:00
2025-08-11 22:55:32 +02:00
//! 'QString' implementation von substr
2025-08-07 10:39:42 +02:00
2025-08-05 22:39:41 +02:00
template<>
QString znode::zpayload<QString>::xstr_sub_str( const QString& entry, int pos ) const
{
return entry.mid(pos);
}
2025-08-07 10:39:42 +02:00
2025-08-11 22:55:32 +02:00
//! 'QString' implementation vom test auf 'empty'
2025-08-07 10:39:42 +02:00
2025-08-05 22:39:41 +02:00
template<>
bool znode::zpayload<QString>::xstr_is_empty(const QString& entry ) const
{
return entry.isEmpty();
}
2025-08-11 22:55:32 +02:00
//! 'QString' varianten der keystrings.
2025-08-07 10:39:42 +02:00
2025-08-05 22:39:41 +02:00
template<>
const QString znode::zpayload<QString>::cType = "Type";
template<>
const QString znode::zpayload<QString>::cName = "Name";
template<>
const QString znode::zpayload<QString>::cValue = "Value";
template<>
const QString znode::zpayload<QString>::cFriendlyName = "FriendlyName";