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