00001 /* $Id: OSglWriter.h 2698 2009-06-09 04:14:07Z kmartin $ */ 00018 #ifndef OSgLWRITER_H 00019 #define OSgLWRITER_H 00020 00021 #include "OSGeneral.h" 00022 #include "OSiLWriter.h" 00023 #include "OSInstance.h" 00024 #include "OSGeneral.h" 00025 #include "OSParameters.h" 00026 #include "OSBase64.h" 00027 #include "OSMathUtil.h" 00028 00029 #include <string> 00030 #include <sstream> 00031 00040 /* 00041 std::string writeIntVectorData(IntVector *v, bool addWhiteSpace, bool writeBase64) 00042 { 00043 ostringstream outStr; 00044 int mult, incr; 00045 00046 if (v->numberOfEl > 0) 00047 { 00048 if(writeBase64 == false) 00049 { 00050 for(int i = 0; i <= v->numberOfEl;) 00051 { 00052 getMultIncr(&(v->el[i]), &mult, &incr, (v->numberOfEl) - i, 1); 00053 if (mult == 1) 00054 outStr << "<el>" ; 00055 else if (incr == 1) 00056 outStr << "<el mult=\"" << mult << "\">"; 00057 else 00058 outStr << "<el mult=\"" << mult << "\" incr=\"" << incr << "\">"; 00059 outStr << v->el[i]; 00060 outStr << "</el>" ; 00061 if(addWhiteSpace == true) outStr << endl; 00062 i += mult; 00063 } 00064 } 00065 else 00066 { 00067 outStr << "<base64BinaryData sizeOf=\"" << sizeof(int) << "\">" ; 00068 outStr << Base64::encodeb64( (char*)v->el, (v->numberOfEl)*sizeof(int) ); 00069 outStr << "</base64BinaryData>" ; 00070 if(addWhiteSpace == true) outStr << endl; 00071 } 00072 } 00073 return outStr.str(); 00074 }// end writeIntVectorData 00075 */ 00076 00085 /* 00086 std::string writeDblVectorData(DoubleVector *v, bool addWhiteSpace, bool writeBase64) 00087 { 00088 ostringstream outStr; 00089 int mult, incr; 00090 00091 if (v->numberOfEl > 0) 00092 { 00093 if(writeBase64 == false) 00094 { 00095 for(int i = 0; i <= v->numberOfEl;) 00096 { 00097 mult = getMult(&(v->el[i]), (v->numberOfEl) - i); 00098 if (mult == 1) 00099 outStr << "<el>" ; 00100 else 00101 outStr << "<el mult=\"" << mult << "\">"; 00102 outStr << os_dtoa_format(v->el[i] ); 00103 outStr << "</el>" ; 00104 if(addWhiteSpace == true) outStr << endl; 00105 i += mult; 00106 } 00107 } 00108 else 00109 { 00110 outStr << "<base64BinaryData sizeOf=\"" << sizeof(double) << "\">" ; 00111 outStr << Base64::encodeb64( (char*)v->el, (v->numberOfEl)*sizeof(double) ); 00112 outStr << "</base64BinaryData>" ; 00113 if(addWhiteSpace == true) outStr << endl; 00114 } 00115 } 00116 return outStr.str(); 00117 }// end writeDblVectorData 00118 */ 00119 00128 /* 00129 std::string writeBasisStatus(BasisStatus *bs, bool addWhiteSpace, bool writeBase64) 00130 { 00131 ostringstream outStr; 00132 00133 if (bs->basic != NULL && bs->basic->numberOfEl > 0) 00134 { 00135 outStr << "<basic numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00136 if(addWhiteSpace == true) outStr << endl; 00137 outStr << writeIntVectorData(bs->basic, addWhiteSpace, writeBase64); 00138 outStr << "</basic>"; 00139 if(addWhiteSpace == true) outStr << endl; 00140 } 00141 00142 if (bs->atLower != NULL && bs->atLower->numberOfEl > 0) 00143 { 00144 outStr << "<basic numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00145 if(addWhiteSpace == true) outStr << endl; 00146 outStr << writeIntVectorData(bs->atLower, addWhiteSpace, writeBase64); 00147 outStr << "</unknown>"; 00148 if(addWhiteSpace == true) outStr << endl; 00149 } 00150 00151 if (bs->atUpper != NULL && bs->atUpper->numberOfEl > 0) 00152 { 00153 outStr << "<basic numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00154 if(addWhiteSpace == true) outStr << endl; 00155 outStr << writeIntVectorData(bs->atUpper, addWhiteSpace, writeBase64); 00156 outStr << "</unknown>"; 00157 if(addWhiteSpace == true) outStr << endl; 00158 } 00159 00160 if (bs->free != NULL && bs->free->numberOfEl > 0) 00161 { 00162 outStr << "<basic numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00163 if(addWhiteSpace == true) outStr << endl; 00164 outStr << writeIntVectorData(bs->free, addWhiteSpace, writeBase64); 00165 outStr << "</unknown>"; 00166 if(addWhiteSpace == true) outStr << endl; 00167 } 00168 00169 if (bs->superbasic != NULL && bs->superbasic->numberOfEl > 0) 00170 { 00171 outStr << "<superbasic numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00172 if(addWhiteSpace == true) outStr << endl; 00173 outStr << writeIntVectorData(bs->superbasic, addWhiteSpace, writeBase64); 00174 outStr << "</unknown>"; 00175 if(addWhiteSpace == true) outStr << endl; 00176 } 00177 00178 if (bs->unknown != NULL && bs->unknown->numberOfEl > 0) 00179 { 00180 outStr << "<unknown numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00181 if(addWhiteSpace == true) outStr << endl; 00182 outStr << writeIntVectorData(bs->unknown, addWhiteSpace, writeBase64); 00183 outStr << "</unknown>"; 00184 if(addWhiteSpace == true) outStr << endl; 00185 } 00186 00187 return outStr.str(); 00188 }// end writeDblVectorData 00189 */ 00190 00199 std::string writeIntVectorData(IntVector *v, bool addWhiteSpace, bool writeBase64); 00200 00201 00208 std::string writeGeneralFileHeader(GeneralFileHeader *v, bool addWhiteSpace); 00209 00218 std::string writeOtherOptionEnumeration(OtherOptionEnumeration *e, bool addWhiteSpace, bool writeBase64); 00219 00220 00229 std::string writeDblVectorData(DoubleVector *v, bool addWhiteSpace, bool writeBase64); 00230 00231 00240 std::string writeBasisStatus(BasisStatus *bs, bool addWhiteSpace, bool writeBase64); 00241 00242 #endif