00001
00019 #include "OSgLWriter.h"
00020 #include "OSGeneral.h"
00021 #include "OSParameters.h"
00022 #include "OSBase64.h"
00023 #include "OSMathUtil.h"
00024 #include "CoinFinite.hpp"
00025
00026 #include <sstream>
00027
00028 using std::cout;
00029 using std::endl;
00030 using std::ostringstream;
00031
00040 std::string writeIntVectorData(IntVector *v, bool addWhiteSpace, bool writeBase64)
00041 {
00042 ostringstream outStr;
00043 int mult, incr;
00044
00045 if (v->numberOfEl > 0)
00046 {
00047 if(writeBase64 == false)
00048 {
00049 for(int i = 0; i < v->numberOfEl;)
00050 {
00051 getMultIncr(&(v->el[i]), &mult, &incr, (v->numberOfEl) - i, 0);
00052 if (mult == 1)
00053 outStr << "<el>" ;
00054 else if (incr == 1)
00055 outStr << "<el mult=\"" << mult << "\">";
00056 else
00057 outStr << "<el mult=\"" << mult << "\" incr=\"" << incr << "\">";
00058 outStr << v->el[i];
00059 outStr << "</el>" ;
00060 if(addWhiteSpace == true) outStr << endl;
00061 i += mult;
00062 }
00063 }
00064 else
00065 {
00066 outStr << "<base64BinaryData sizeOf=\"" << sizeof(int) << "\">" ;
00067 outStr << Base64::encodeb64( (char*)v->el, (v->numberOfEl)*sizeof(int) );
00068 outStr << "</base64BinaryData>" ;
00069 if(addWhiteSpace == true) outStr << endl;
00070 }
00071 }
00072 return outStr.str();
00073 }
00074
00075
00084 std::string writeOtherOptionEnumeration(OtherOptionEnumeration *e, bool addWhiteSpace, bool writeBase64)
00085 {
00086 ostringstream outStr;
00087
00088 outStr << "<enumeration ";
00089 outStr << "numberOfEl=\"" << e->numberOfEl << "\" ";
00090 if (e->value != "") outStr << "value=\"" << e->value << "\" ";
00091 if (e->description != "") outStr << "description=\"" << e->description << "\" ";
00092 outStr << ">";
00093 outStr << writeIntVectorData(e, addWhiteSpace, writeBase64);
00094 outStr << "</enumeration>";
00095 return outStr.str();
00096 }
00097
00098
00099
00108 std::string writeDblVectorData(DoubleVector *v, bool addWhiteSpace, bool writeBase64)
00109 {
00110 ostringstream outStr;
00111 int mult, incr;
00112
00113 if (v->numberOfEl > 0)
00114 {
00115 if(writeBase64 == false)
00116 {
00117 for(int i = 0; i < v->numberOfEl;)
00118 {
00119 mult = getMult(&(v->el[i]), (v->numberOfEl) - i);
00120 if (mult == 1)
00121 outStr << "<el>" ;
00122 else
00123 outStr << "<el mult=\"" << mult << "\">";
00124 outStr << os_dtoa_format(v->el[i] );
00125 outStr << "</el>" ;
00126 if(addWhiteSpace == true) outStr << endl;
00127 i += mult;
00128 }
00129 }
00130 else
00131 {
00132 outStr << "<base64BinaryData sizeOf=\"" << sizeof(double) << "\">" ;
00133 outStr << Base64::encodeb64( (char*)v->el, (v->numberOfEl)*sizeof(double) );
00134 outStr << "</base64BinaryData>" ;
00135 if(addWhiteSpace == true) outStr << endl;
00136 }
00137 }
00138 return outStr.str();
00139 }
00140
00141
00150 std::string writeBasisStatus(BasisStatus *bs, bool addWhiteSpace, bool writeBase64)
00151 {
00152 ostringstream outStr;
00153 outStr << "<basisStatus>" << endl;
00154
00155 if (bs->basic != NULL && bs->basic->numberOfEl > 0)
00156 {
00157 outStr << "<basic numberOfEl=\"" << bs->basic->numberOfEl << "\">";
00158 if(addWhiteSpace == true) outStr << endl;
00159 outStr << writeIntVectorData(bs->basic, addWhiteSpace, writeBase64);
00160 outStr << "</basic>";
00161 if(addWhiteSpace == true) outStr << endl;
00162 }
00163
00164 if (bs->atLower != NULL && bs->atLower->numberOfEl > 0)
00165 {
00166 outStr << "<atLower numberOfEl=\"" << bs->atLower->numberOfEl << "\">";
00167 if(addWhiteSpace == true) outStr << endl;
00168 outStr << writeIntVectorData(bs->atLower, addWhiteSpace, writeBase64);
00169 outStr << "</atLower>";
00170 if(addWhiteSpace == true) outStr << endl;
00171 }
00172
00173 if (bs->atUpper != NULL && bs->atUpper->numberOfEl > 0)
00174 {
00175 outStr << "<atUpper numberOfEl=\"" << bs->atUpper->numberOfEl << "\">";
00176 if(addWhiteSpace == true) outStr << endl;
00177 outStr << writeIntVectorData(bs->atUpper, addWhiteSpace, writeBase64);
00178 outStr << "</atUpper>";
00179 if(addWhiteSpace == true) outStr << endl;
00180 }
00181
00182 if (bs->isFree != NULL && bs->isFree->numberOfEl > 0)
00183 {
00184 outStr << "<isFree numberOfEl=\"" << bs->isFree->numberOfEl << "\">";
00185 if(addWhiteSpace == true) outStr << endl;
00186 outStr << writeIntVectorData(bs->isFree, addWhiteSpace, writeBase64);
00187 outStr << "</isFree>";
00188 if(addWhiteSpace == true) outStr << endl;
00189 }
00190
00191 if (bs->superbasic != NULL && bs->superbasic->numberOfEl > 0)
00192 {
00193 outStr << "<superbasic numberOfEl=\"" << bs->superbasic->numberOfEl << "\">";
00194 if(addWhiteSpace == true) outStr << endl;
00195 outStr << writeIntVectorData(bs->superbasic, addWhiteSpace, writeBase64);
00196 outStr << "</superbasic>";
00197 if(addWhiteSpace == true) outStr << endl;
00198 }
00199
00200 if (bs->unknown != NULL && bs->unknown->numberOfEl > 0)
00201 {
00202 outStr << "<unknown numberOfEl=\"" << bs->unknown->numberOfEl << "\">";
00203 if(addWhiteSpace == true) outStr << endl;
00204 outStr << writeIntVectorData(bs->unknown, addWhiteSpace, writeBase64);
00205 outStr << "</unknown>";
00206 if(addWhiteSpace == true) outStr << endl;
00207 }
00208
00209 outStr << "</basisStatus>" << endl;
00210
00211 return outStr.str();
00212 }