aboutsummaryrefslogtreecommitdiff
path: root/c++-qt/src/list.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2022-04-06 23:45:42 -0700
committerMike Buland <eichlan@xagasoft.com>2022-04-06 23:45:42 -0700
commit3cbd1038e20dcb2b25db4e74666ec21766642729 (patch)
tree1fab95855d344196a44feadda75bfc0a5a63b61f /c++-qt/src/list.cpp
parentb522669649e81c61c6a5e390991b8fd70bfdeed9 (diff)
downloadlibgats-3cbd1038e20dcb2b25db4e74666ec21766642729.tar.gz
libgats-3cbd1038e20dcb2b25db4e74666ec21766642729.tar.bz2
libgats-3cbd1038e20dcb2b25db4e74666ec21766642729.tar.xz
libgats-3cbd1038e20dcb2b25db4e74666ec21766642729.zip
toString works.
It does indent automatically. I figure, you know, if you're converting to a string then a big part of the reason is so you can read it. In that case, why make it optional?
Diffstat (limited to '')
-rw-r--r--c++-qt/src/list.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/c++-qt/src/list.cpp b/c++-qt/src/list.cpp
index fae51d1..cca7c46 100644
--- a/c++-qt/src/list.cpp
+++ b/c++-qt/src/list.cpp
@@ -48,7 +48,7 @@ void Gats::List::write( QIODevice &rOut ) const
48 rOut.write("e", 1 ); 48 rOut.write("e", 1 );
49} 49}
50 50
51void Gats::List::read( QIODevice &rIn, char cType ) 51void Gats::List::read( QIODevice &rIn, char /*cType*/ )
52{ 52{
53 for(;;) 53 for(;;)
54 { 54 {
@@ -59,6 +59,32 @@ void Gats::List::read( QIODevice &rIn, char cType )
59 } 59 }
60} 60}
61 61
62QString Gats::List::toString( int iIndent ) const
63{
64 if( count() == 0 )
65 return "[ ]";
66 QString sRet("[");
67 iIndent++;
68 for( const_iterator i = begin(); i != end(); i++ )
69 {
70 if( i != begin() )
71 {
72 sRet += ",\n";
73 }
74 else
75 {
76 sRet += "\n";
77 }
78 for( int j = 0; j < iIndent; j++ ) sRet += " ";
79 sRet += (*i)->toString( iIndent );
80 }
81 sRet += "\n";
82 iIndent--;
83 for( int j = 0; j < iIndent; j++ ) sRet += " ";
84 sRet += ']';
85 return sRet;
86}
87
62void Gats::List::append( const char *s ) 88void Gats::List::append( const char *s )
63{ 89{
64 QList<Gats::Object *>::append( new Gats::String( s ) ); 90 QList<Gats::Object *>::append( new Gats::String( s ) );