summaryrefslogtreecommitdiffstats
path: root/examples/network/infoprotocol/infoserver/infodata.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/network/infoprotocol/infoserver/infodata.cpp
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/network/infoprotocol/infoserver/infodata.cpp')
-rw-r--r--examples/network/infoprotocol/infoserver/infodata.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/examples/network/infoprotocol/infoserver/infodata.cpp b/examples/network/infoprotocol/infoserver/infodata.cpp
new file mode 100644
index 000000000..347c78d31
--- /dev/null
+++ b/examples/network/infoprotocol/infoserver/infodata.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "infodata.h"
+
+
+// we hard code all nodes and data in InfoData class
+InfoData::InfoData() :
+ nodes( 17, TRUE ), data( 17, TRUE )
+{
+ nodes.setAutoDelete(TRUE);
+ data.setAutoDelete(TRUE);
+ TQStringList *item;
+
+ nodes.insert( "/", item = new TQStringList( ) );
+ (*item) << "D network";
+ nodes.insert( "/network/", item = new TQStringList() );
+ (*item) << "D workstations" << "D printers" << "D fax";
+ nodes.insert( "/network/workstations/", item = new TQStringList() );
+ (*item) << "D nibble" << "D douglas";
+ nodes.insert( "/network/workstations/nibble/", item = new TQStringList() );
+ (*item) << "F os" << "F cpu" << "F memory";
+ nodes.insert( "/network/workstations/douglas/", item = new TQStringList() );
+ (*item) << "F os" << "F cpu" << "F memory";
+ nodes.insert( "/network/printers/", item = new TQStringList() );
+ (*item) << "D overbitt" << "D kroksleiven";
+ nodes.insert( "/network/printers/overbitt/", item = new TQStringList() );
+ (*item) << "D jobs" << "F type";
+ nodes.insert( "/network/printers/overbitt/jobs/", item = new TQStringList() );
+ (*item) << "F job1" << "F job2";
+ nodes.insert( "/network/printers/kroksleiven/", item = new TQStringList() );
+ (*item) << "D jobs" << "F type";
+ nodes.insert( "/network/printers/kroksleiven/jobs/", item = new TQStringList() );
+ nodes.insert( "/network/fax/", item = new TQStringList() );
+ (*item) << "F last_number";
+
+ data.insert( "/network/workstations/nibble/os", new TQString( "Linux" ) );
+ data.insert( "/network/workstations/nibble/cpu", new TQString( "AMD Athlon 1000" ) );
+ data.insert( "/network/workstations/nibble/memory", new TQString( "256 MB" ) );
+ data.insert( "/network/workstations/douglas/os", new TQString( "Windows 2000" ) );
+ data.insert( "/network/workstations/douglas/cpu", new TQString( "2 x Intel Pentium III 800" ) );
+ data.insert( "/network/workstations/douglas/memory", new TQString( "256 MB" ) );
+ data.insert( "/network/printers/overbitt/type", new TQString( "Lexmark Optra S 1255 PS" ) );
+ data.insert( "/network/printers/overbitt/jobs/job1",
+ new TQString( "TQt manual\n" "A4 size\n" "3000 pages" ) );
+ data.insert( "/network/printers/overbitt/jobs/job2",
+ new TQString( "Monthly report\n" "Letter size\n" "24 pages\n" "8 copies" ) );
+ data.insert( "/network/printers/kroksleiven/type", new TQString( "HP C LaserJet 4500-PS" ) );
+ data.insert( "/network/fax/last_number", new TQString( "22 22 22 22" ) );
+}
+
+TQStringList InfoData::list( TQString path, bool *found ) const
+{
+ if ( !path.endsWith( "/" ) )
+ path += "/";
+ if ( !path.startsWith( "/" ) )
+ path = "/" + path;
+ TQStringList *list = nodes[ path ];
+ if ( list ) {
+ *found = TRUE;
+ return *list;
+ } else {
+ *found = FALSE;
+ TQStringList empty;
+ return empty;
+ }
+}
+
+TQString InfoData::get( TQString path, bool *found ) const
+{
+ if ( !path.startsWith( "/" ) )
+ path = "/" + path;
+ TQString *file = data[ path ];
+ if ( file ) {
+ *found = TRUE;
+ return *file;
+ } else {
+ *found = FALSE;
+ TQString empty;
+ return empty;
+ }
+}