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 #include "CoinFinite.hpp" 00029 00030 #include <string> 00031 #include <sstream> 00032 00033 using std::cout; 00034 using std::endl; 00035 using std::ostringstream; 00036 00045 /* 00046 std::string writeIntVectorData(IntVector *v, bool addWhiteSpace, bool writeBase64) 00047 { 00048 ostringstream outStr; 00049 int mult, incr; 00050 00051 if (v->numberOfEl > 0) 00052 { 00053 if(writeBase64 == false) 00054 { 00055 for(int i = 0; i <= v->numberOfEl;) 00056 { 00057 getMultIncr(&(v->el[i]), &mult, &incr, (v->numberOfEl) - i, 1); 00058 if (mult == 1) 00059 outStr << "<el>" ; 00060 else if (incr == 1) 00061 outStr << "<el mult=\"" << mult << "\">"; 00062 else 00063 outStr << "<el mult=\"" << mult << "\" incr=\"" << incr << "\">"; 00064 outStr << v->el[i]; 00065 outStr << "</el>" ; 00066 if(addWhiteSpace == true) outStr << endl; 00067 i += mult; 00068 } 00069 } 00070 else 00071 { 00072 outStr << "<base64BinaryData sizeOf=\"" << sizeof(int) << "\">" ; 00073 outStr << Base64::encodeb64( (char*)v->el, (v->numberOfEl)*sizeof(int) ); 00074 outStr << "</base64BinaryData>" ; 00075 if(addWhiteSpace == true) outStr << endl; 00076 } 00077 } 00078 return outStr.str(); 00079 }// end writeIntVectorData 00080 */ 00081 00090 /* 00091 std::string writeDblVectorData(DoubleVector *v, bool addWhiteSpace, bool writeBase64) 00092 { 00093 ostringstream outStr; 00094 int mult, incr; 00095 00096 if (v->numberOfEl > 0) 00097 { 00098 if(writeBase64 == false) 00099 { 00100 for(int i = 0; i <= v->numberOfEl;) 00101 { 00102 mult = getMult(&(v->el[i]), (v->numberOfEl) - i); 00103 if (mult == 1) 00104 outStr << "<el>" ; 00105 else 00106 outStr << "<el mult=\"" << mult << "\">"; 00107 outStr << os_dtoa_format(v->el[i] ); 00108 outStr << "</el>" ; 00109 if(addWhiteSpace == true) outStr << endl; 00110 i += mult; 00111 } 00112 } 00113 else 00114 { 00115 outStr << "<base64BinaryData sizeOf=\"" << sizeof(double) << "\">" ; 00116 outStr << Base64::encodeb64( (char*)v->el, (v->numberOfEl)*sizeof(double) ); 00117 outStr << "</base64BinaryData>" ; 00118 if(addWhiteSpace == true) outStr << endl; 00119 } 00120 } 00121 return outStr.str(); 00122 }// end writeDblVectorData 00123 */ 00124 00133 /* 00134 std::string writeBasisStatus(BasisStatus *bs, bool addWhiteSpace, bool writeBase64) 00135 { 00136 ostringstream outStr; 00137 00138 if (bs->basic != NULL && bs->basic->numberOfEl > 0) 00139 { 00140 outStr << "<basic numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00141 if(addWhiteSpace == true) outStr << endl; 00142 outStr << writeIntVectorData(bs->basic, addWhiteSpace, writeBase64); 00143 outStr << "</basic>"; 00144 if(addWhiteSpace == true) outStr << endl; 00145 } 00146 00147 if (bs->atLower != NULL && bs->atLower->numberOfEl > 0) 00148 { 00149 outStr << "<basic numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00150 if(addWhiteSpace == true) outStr << endl; 00151 outStr << writeIntVectorData(bs->atLower, addWhiteSpace, writeBase64); 00152 outStr << "</unknown>"; 00153 if(addWhiteSpace == true) outStr << endl; 00154 } 00155 00156 if (bs->atUpper != NULL && bs->atUpper->numberOfEl > 0) 00157 { 00158 outStr << "<basic numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00159 if(addWhiteSpace == true) outStr << endl; 00160 outStr << writeIntVectorData(bs->atUpper, addWhiteSpace, writeBase64); 00161 outStr << "</unknown>"; 00162 if(addWhiteSpace == true) outStr << endl; 00163 } 00164 00165 if (bs->free != NULL && bs->free->numberOfEl > 0) 00166 { 00167 outStr << "<basic numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00168 if(addWhiteSpace == true) outStr << endl; 00169 outStr << writeIntVectorData(bs->free, addWhiteSpace, writeBase64); 00170 outStr << "</unknown>"; 00171 if(addWhiteSpace == true) outStr << endl; 00172 } 00173 00174 if (bs->superbasic != NULL && bs->superbasic->numberOfEl > 0) 00175 { 00176 outStr << "<superbasic numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00177 if(addWhiteSpace == true) outStr << endl; 00178 outStr << writeIntVectorData(bs->superbasic, addWhiteSpace, writeBase64); 00179 outStr << "</unknown>"; 00180 if(addWhiteSpace == true) outStr << endl; 00181 } 00182 00183 if (bs->unknown != NULL && bs->unknown->numberOfEl > 0) 00184 { 00185 outStr << "<unknown numberOfEl=\"" << bs->basic->numberOfEl << "\">"; 00186 if(addWhiteSpace == true) outStr << endl; 00187 outStr << writeIntVectorData(bs->unknown, addWhiteSpace, writeBase64); 00188 outStr << "</unknown>"; 00189 if(addWhiteSpace == true) outStr << endl; 00190 } 00191 00192 return outStr.str(); 00193 }// end writeDblVectorData 00194 */ 00195 00204 std::string writeIntVectorData(IntVector *v, bool addWhiteSpace, bool writeBase64); 00205 00206 00213 std::string writeGeneralFileHeader(GeneralFileHeader *v, bool addWhiteSpace); 00214 00223 std::string writeOtherOptionEnumeration(OtherOptionEnumeration *e, bool addWhiteSpace, bool writeBase64); 00224 00225 00234 std::string writeDblVectorData(DoubleVector *v, bool addWhiteSpace, bool writeBase64); 00235 00236 00245 std::string writeBasisStatus(BasisStatus *bs, bool addWhiteSpace, bool writeBase64); 00246 00247 #endif