1 // StringContent.cpp 2 3 #include "StringContent.h" 4 #include "ImportContext.h" 5 6 #include <cctype> 7 8 __USE_CORTEX_NAMESPACE 9 10 // -------------------------------------------------------- // 11 // EXPORT [not implemented] 12 // -------------------------------------------------------- // 13 14 void StringContent::xmlExportBegin( 15 ExportContext& context) const { 16 context.reportError("StringContent: no export"); 17 } 18 void StringContent::xmlExportAttributes( 19 ExportContext& context) const { 20 context.reportError("StringContent: no export"); 21 } 22 void StringContent::xmlExportContent( 23 ExportContext& context) const { 24 context.reportError("StringContent: no export"); 25 } 26 void StringContent::xmlExportEnd( 27 ExportContext& context) const { 28 context.reportError("StringContent: no export"); 29 } 30 31 // -------------------------------------------------------- // 32 // IMPORT 33 // -------------------------------------------------------- // 34 35 void StringContent::xmlImportBegin( 36 ImportContext& context) {} 37 38 void StringContent::xmlImportAttribute( 39 const char* key, 40 const char* value, 41 ImportContext& context) {} 42 43 void StringContent::xmlImportContent( 44 const char* data, 45 uint32 length, 46 ImportContext& context) { 47 content.Append(data, length); 48 } 49 50 void StringContent::xmlImportChild( 51 IPersistent* child, 52 ImportContext& context) { 53 context.reportError("StringContent: child not expected"); 54 } 55 56 void StringContent::xmlImportComplete( 57 ImportContext& context) { 58 59 // chomp leading/trailing whitespace 60 if(content.Length() == 0) 61 return; 62 63 int32 last = 0; 64 for(; last < content.Length() && isspace(content[last]); ++last) {} 65 if(last > 0) 66 content.Remove(0, last); 67 68 last = content.Length() - 1; 69 int32 from = last; 70 for(; from > 0 && isspace(content[from]); --from) {} 71 if(from < last) 72 content.Remove(from+1, last-from); 73 } 74 75 // END -- StringContent.cpp -- 76 77