1 // 2 // This file is part of the SDTS++ toolkit, written by the U.S. 3 // Geological Survey. It is experimental software, written to support 4 // USGS research and cartographic data production. 5 // 6 // SDTS++ is public domain software. It may be freely copied, 7 // distributed, and modified. The USGS welcomes user feedback, but makes 8 // no committment to any level of support for this code. See the SDTS 9 // web site at http://mcmcweb.er.usgs.gov/sdts for more information, 10 // including points of contact. 11 // 12 13 14 #include <iostream> 15 #include <fstream> 16 17 #include <cassert> 18 19 20 #include <sdts++/io/sio_8211Converter.h> 21 #include <sdts++/io/sio_Reader.h> 22 #include <sdts++/container/sc_Record.h> 23 #include <sdts++/builder/sb_Cats.h> 24 25 26 using namespace std; 27 28 29 30 int main(int argc,char ** argv)31main( int argc, char** argv ) 32 { 33 34 if ( ! argv[1] ) 35 { 36 cout << "skipping read/write tests ..." << endl; 37 } 38 else 39 { 40 #ifdef WIN32 41 ifstream ddf( argv[1], ios::binary ); 42 #else 43 ifstream ddf( argv[1] ); 44 #endif 45 46 if ( ! ddf ) 47 { 48 cerr << "couldn't open " << argv[1] << endl; 49 exit( 2 ); 50 } 51 52 sio_8211Reader reader( ddf ); 53 sc_Record record; 54 sio_8211ForwardIterator i( reader ); 55 56 { 57 58 sb_Cats cats; 59 60 while ( i ) 61 { 62 if ( ! i.get( record ) ) break; 63 64 cout << "what we read in:\n\n"; 65 cout << record << endl; 66 67 cats.setRecord( record ); 68 69 cout << "\nand what the CATS object says it is:\n"; 70 cout << cats << endl; 71 72 cout << "\nand what the record build from the CATS object says it is:\n"; 73 cats.getRecord( record ); 74 cout << record << endl; 75 76 cout << "***\n\n"; 77 78 ++i; 79 } 80 } 81 82 } // read/write tests 83 84 // test building an CATS from scratch 85 { 86 sb_Cats cats; 87 88 assert( cats.setName( "is NAME" ) ); 89 90 assert( cats.setType( "is TYPE" ) ); 91 92 assert( cats.setDomain( "is Domain" ) ); 93 94 assert( cats.setMap( "is Map" ) ); 95 96 assert( cats.setThem( "is Theme" ) ); 97 98 assert( cats.setAggregateObject( "is Aggregate Object" ) ); 99 100 assert( cats.setAggregateObjectType( "is Aggregate Object Type" ) ); 101 102 assert( cats.setComment( "is Comment" ) ); 103 104 105 cout << cats << endl; 106 } 107 108 exit( 0 ); 109 110 } 111