Changeset 8215
- Timestamp:
- 05/09/11 15:21:32 (14 years ago)
- Location:
- issm/trunk/src/c/objects/KML
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/KML/KML_Container.cpp
r8208 r8215 23 23 KML_Container::KML_Container(){ 24 24 25 ;25 feature =new DataSet; 26 26 27 27 } … … 30 30 KML_Container::~KML_Container(){ 31 31 32 ; 32 if (feature) { 33 delete feature; 34 feature =NULL; 35 } 33 36 34 37 } … … 39 42 void KML_Container::Echo(){ 40 43 44 bool flag=true; 45 41 46 KML_Feature::Echo(); 47 48 _printf_(flag," feature: (size=%d)\n" ,feature->Size()); 42 49 43 50 return; … … 59 66 void KML_Container::DeepEcho(char* indent){ 60 67 68 int i; 69 char indent2[81]; 70 bool flag=true; 71 61 72 KML_Feature::DeepEcho(indent); 73 74 /* loop over the features for the container */ 75 76 strcpy(indent2,indent); 77 strcat(indent2," "); 78 79 if (feature->Size()) 80 for (i=0; i<feature->Size(); i++) { 81 _printf_(flag,"%s feature: [%d] begin\n" ,indent,i); 82 ((KML_Feature *)feature->GetObjectByOffset(i))->DeepEcho(indent2); 83 _printf_(flag,"%s feature: [%d] end\n" ,indent,i); 84 } 85 else 86 _printf_(flag,"%s feature: [empty]\n" ,indent); 62 87 63 88 return; … … 68 93 void KML_Container::Write(FILE* filout,char* indent){ 69 94 95 int i; 96 char indent2[81]; 97 70 98 KML_Feature::Write(filout,indent); 99 100 /* loop over the features for the container */ 101 102 strcpy(indent2,indent); 103 strcat(indent2," "); 104 105 for (i=0; i<feature->Size(); i++) 106 ((KML_Feature *)feature->GetObjectByOffset(i))->Write(filout,indent2); 71 107 72 108 return; … … 77 113 void KML_Container::Read(FILE* fid,char* kstr){ 78 114 79 KML_Feature::Read(fid,kstr); 115 KML_Object* kobj; 116 117 /* process field within opening and closing tags */ 118 119 if (!strncmp(kstr,"</Container",11)) { 120 xfree((void**)&kstr); 121 return; 122 } 123 else if (!strncmp(kstr,"</",2)) 124 _error_("KML_Container::Read -- Unexpected closing tag %s.\n",kstr); 125 else if (strncmp(kstr,"<",1)) 126 _error_("KML_Container::Read -- Unexpected field \"%s\".\n",kstr); 127 128 else if (!strncmp(kstr,"<Placemark",10)) { 129 kobj=(KML_Object*)new KML_Placemark(); 130 kobj->Read(fid,kstr); 131 feature ->AddObject((Object*)kobj); 132 } 133 134 else if (!strncmp(kstr,"<Folder",7)) { 135 kobj=(KML_Object*)new KML_Folder(); 136 kobj->Read(fid,kstr); 137 feature ->AddObject((Object*)kobj); 138 } 139 140 else if (!strncmp(kstr,"<Document",9)) { 141 kobj=(KML_Object*)new KML_Document(); 142 kobj->Read(fid,kstr); 143 feature ->AddObject((Object*)kobj); 144 } 145 146 else if (!strncmp(kstr,"<",1)) 147 KML_Feature::Read(fid,kstr); 80 148 81 149 return; -
issm/trunk/src/c/objects/KML/KML_Container.h
r8208 r8215 18 18 19 19 public: 20 21 DataSet* feature; 20 22 21 23 /*KML_Container constructors, destructors {{{1*/ -
issm/trunk/src/c/objects/KML/KML_Document.cpp
r8208 r8215 23 23 KML_Document::KML_Document(){ 24 24 25 feature =new DataSet;25 ; 26 26 27 27 } … … 30 30 KML_Document::~KML_Document(){ 31 31 32 if (feature) { 33 delete feature; 34 feature =NULL; 35 } 32 ; 36 33 37 34 } … … 46 43 _printf_(flag,"KML_Document:\n"); 47 44 KML_Container::Echo(); 48 49 _printf_(flag," feature: (size=%d)\n" ,feature->Size());50 45 51 46 return; … … 67 62 void KML_Document::DeepEcho(char* indent){ 68 63 69 int i;70 char indent2[81];71 64 bool flag=true; 72 65 73 66 _printf_(flag,"%sKML_Document:\n",indent); 74 67 KML_Container::DeepEcho(indent); 75 76 /* loop over the features for the document */77 78 strcpy(indent2,indent);79 strcat(indent2," ");80 81 if (feature->Size())82 for (i=0; i<feature->Size(); i++) {83 _printf_(flag,"%s feature: [%d] begin\n" ,indent,i);84 ((KML_Feature *)feature->GetObjectByOffset(i))->DeepEcho(indent2);85 _printf_(flag,"%s feature: [%d] end\n" ,indent,i);86 }87 else88 _printf_(flag,"%s feature: [empty]\n" ,indent);89 68 90 69 return; … … 95 74 void KML_Document::Write(FILE* filout,char* indent){ 96 75 97 int i;98 char indent2[81];99 100 76 if (this->id && strlen(this->id)) 101 77 fprintf(filout,"%s<Document id=\"%s\">\n",indent,this->id); … … 104 80 105 81 KML_Container::Write(filout,indent); 106 107 /* loop over the features for the document */108 109 strcpy(indent2,indent);110 strcat(indent2," ");111 112 for (i=0; i<feature->Size(); i++)113 ((KML_Feature *)feature->GetObjectByOffset(i))->Write(filout,indent2);114 82 115 83 fprintf(filout,"%s</Document>\n",indent); … … 123 91 124 92 char* kstri; 125 KML_Object* kobj;126 93 127 94 /* check for id attribute */ … … 143 110 else if (strncmp(kstri,"<",1)) 144 111 _error_("KML_Document::Read -- Unexpected field \"%s\".\n",kstri); 145 146 else if (!strncmp(kstri,"<Placemark",10)) {147 kobj=(KML_Object*)new KML_Placemark();148 kobj->Read(fid,kstri);149 feature ->AddObject((Object*)kobj);150 }151 152 else if (!strncmp(kstri,"<Folder",7)) {153 kobj=(KML_Object*)new KML_Folder();154 kobj->Read(fid,kstri);155 feature ->AddObject((Object*)kobj);156 }157 158 else if (!strncmp(kstri,"<Document",9)) {159 kobj=(KML_Object*)new KML_Document();160 kobj->Read(fid,kstri);161 feature ->AddObject((Object*)kobj);162 }163 112 164 113 else if (!strncmp(kstri,"<",1)) -
issm/trunk/src/c/objects/KML/KML_Document.h
r8208 r8215 20 20 21 21 public: 22 23 DataSet* feature;24 22 25 23 /*KML_Document constructors, destructors {{{1*/ -
issm/trunk/src/c/objects/KML/KML_Folder.cpp
r8208 r8215 23 23 KML_Folder::KML_Folder(){ 24 24 25 feature =new DataSet;25 ; 26 26 27 27 } … … 30 30 KML_Folder::~KML_Folder(){ 31 31 32 if (feature) { 33 delete feature; 34 feature =NULL; 35 } 32 ; 36 33 37 34 } … … 46 43 _printf_(flag,"KML_Folder:\n"); 47 44 KML_Container::Echo(); 48 49 _printf_(flag," feature: (size=%d)\n" ,feature->Size());50 45 51 46 return; … … 67 62 void KML_Folder::DeepEcho(char* indent){ 68 63 69 int i;70 char indent2[81];71 64 bool flag=true; 72 65 73 66 _printf_(flag,"%sKML_Folder:\n",indent); 74 67 KML_Container::DeepEcho(indent); 75 76 /* loop over the features for the folder */77 78 strcpy(indent2,indent);79 strcat(indent2," ");80 81 if (feature->Size())82 for (i=0; i<feature->Size(); i++) {83 _printf_(flag,"%s feature: [%d] begin\n" ,indent,i);84 ((KML_Feature *)feature->GetObjectByOffset(i))->DeepEcho(indent2);85 _printf_(flag,"%s feature: [%d] end\n" ,indent,i);86 }87 else88 _printf_(flag,"%s feature: [empty]\n" ,indent);89 68 90 69 return; … … 96 75 97 76 int i; 98 char indent2[81];99 77 100 78 if (this->id && strlen(this->id)) … … 105 83 KML_Container::Write(filout,indent); 106 84 107 /* loop over the features for the folder */108 109 strcpy(indent2,indent);110 strcat(indent2," ");111 112 for (i=0; i<feature->Size(); i++)113 ((KML_Feature *)feature->GetObjectByOffset(i))->Write(filout,indent2);114 115 85 fprintf(filout,"%s</Folder>\n",indent); 116 86 … … 120 90 121 91 /*FUNCTION KML_Folder::Read {{{1*/ 122 void KML_Folder::Read(FILE* fi lin,char* kstr){92 void KML_Folder::Read(FILE* fid,char* kstr){ 123 93 124 94 -
issm/trunk/src/c/objects/KML/KML_Folder.h
r8208 r8215 20 20 21 21 public: 22 23 DataSet* feature;24 22 25 23 /*KML_Folder constructors, destructors {{{1*/
Note:
See TracChangeset
for help on using the changeset viewer.