1 // File : SALOMEDS_AttributeTableOfString.cxx
2 // Author : Sergey RUIN
5 #include "SALOMEDS_AttributeTableOfString.hxx"
8 #include <TCollection_AsciiString.hxx>
9 #include <TCollection_ExtendedString.hxx>
10 #include <TColStd_HSequenceOfInteger.hxx>
11 #include <TColStd_HSequenceOfReal.hxx>
12 #include <TColStd_HSequenceOfExtendedString.hxx>
14 SALOMEDS_AttributeTableOfString
15 ::SALOMEDS_AttributeTableOfString(const Handle(SALOMEDSImpl_AttributeTableOfString)& theAttr)
16 :SALOMEDS_GenericAttribute(theAttr)
19 SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString(SALOMEDS::AttributeTableOfString_ptr theAttr)
20 :SALOMEDS_GenericAttribute(theAttr)
23 SALOMEDS_AttributeTableOfString::~SALOMEDS_AttributeTableOfString()
27 void SALOMEDS_AttributeTableOfString::SetTitle(const std::string& theTitle)
30 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str());
31 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
34 std::string SALOMEDS_AttributeTableOfString::GetTitle()
38 aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetTitle()).ToCString();
39 else aStr = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetTitle();
43 void SALOMEDS_AttributeTableOfString::SetRowTitle(int theIndex, const std::string& theTitle)
46 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowTitle(theIndex,
47 (char*)theTitle.c_str());
48 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
51 void SALOMEDS_AttributeTableOfString::SetRowTitles(const std::vector<std::string>& theTitles)
54 int aLength = theTitles.size(), i;
56 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
57 for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
58 Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowTitles(aSeq);
61 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
62 aSeq->length(aLength);
63 for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
64 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitles(aSeq);
69 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRowTitles()
71 std::vector<std::string> aVector;
74 Handle(TColStd_HSequenceOfExtendedString) aSeq;
75 aSeq = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetRowTitles();
76 aLength = aSeq->Length();
77 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
80 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowTitles();
81 aLength = aSeq->length();
82 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
87 void SALOMEDS_AttributeTableOfString::SetColumnTitle(int theIndex, const std::string& theTitle)
90 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetColumnTitle(theIndex,
91 (char*)theTitle.c_str());
92 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
95 void SALOMEDS_AttributeTableOfString::SetColumnTitles(const std::vector<std::string>& theTitles)
98 int aLength = theTitles.size(), i;
100 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
101 for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
102 Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetColumnTitles(aSeq);
105 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
106 aSeq->length(aLength);
107 for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
108 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitles(aSeq);
112 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetColumnTitles()
114 std::vector<std::string> aVector;
117 Handle(TColStd_HSequenceOfExtendedString) aSeq;
118 aSeq = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetColumnTitles();
119 aLength = aSeq->Length();
120 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
123 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumnTitles();
124 aLength = aSeq->length();
125 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
130 void SALOMEDS_AttributeTableOfString::SetRowUnit(int theIndex, const std::string& theUnit)
133 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowUnit(theIndex,
134 (char*)theUnit.c_str());
135 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
138 void SALOMEDS_AttributeTableOfString::SetRowUnits(const std::vector<std::string>& theUnits)
141 int aLength = theUnits.size(), i;
143 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
144 for(i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str());
145 Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowUnits(aSeq);
148 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
149 aSeq->length(aLength);
150 for(i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
151 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnits(aSeq);
155 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRowUnits()
157 std::vector<std::string> aVector;
160 Handle(TColStd_HSequenceOfExtendedString) aSeq;
161 aSeq = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetRowUnits();
162 aLength = aSeq->Length();
163 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
166 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowUnits();
167 aLength = aSeq->length();
168 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
173 int SALOMEDS_AttributeTableOfString::GetNbRows()
176 if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetNbRows();
177 else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbRows();
181 int SALOMEDS_AttributeTableOfString::GetNbColumns()
184 if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetNbColumns();
185 else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbColumns();
190 void SALOMEDS_AttributeTableOfString::AddRow(const std::vector<std::string>& theData)
193 int aLength = theData.size(), i;
195 Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
196 aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl);
197 Handle(TColStd_HSequenceOfExtendedString) aRow = new TColStd_HSequenceOfExtendedString;
198 for (int i = 0; i < aLength; i++) aRow->Append((char*)theData[i].c_str());
200 aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
203 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
207 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
208 aSeq->length(aLength);
209 for(i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str();
210 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddRow(aSeq);
214 void SALOMEDS_AttributeTableOfString::SetRow(int theRow, const std::vector<std::string>& theData)
217 int aLength = theData.size(), i;
219 Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
220 aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl);
221 Handle(TColStd_HSequenceOfExtendedString) aRow = new TColStd_HSequenceOfExtendedString;
222 for (int i = 0; i < aLength; i++) aRow->Append((char*)theData[i].c_str());
224 aTable->SetRowData(theRow, aRow);
227 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
231 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
232 aSeq->length(aLength);
233 for(i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str();
234 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRow(theRow, aSeq);
238 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRow(int theRow)
240 std::vector<std::string> aVector;
243 Handle(TColStd_HSequenceOfExtendedString) aRow;
244 aRow = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetRowData(theRow);
245 aLength = aRow->Length();
246 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aRow->Value(i)).ToCString());
249 SALOMEDS::StringSeq_var aRow = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRow(theRow);
250 for(i = 0; i < aLength; i++) aVector.push_back((char*)aRow[i].in());
256 void SALOMEDS_AttributeTableOfString::AddColumn(const std::vector<std::string>& theData)
259 int aLength = theData.size(), i;
261 Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
262 aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl);
263 Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString;
264 for (int i = 0; i < aLength; i++) aColumn->Append((char*)theData[i].c_str());
266 aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
269 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
273 SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
274 aColumn->length(aLength);
275 for(i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str();
276 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddColumn(aColumn);
280 void SALOMEDS_AttributeTableOfString::SetColumn(int theColumn, const std::vector<std::string>& theData)
283 int aLength = theData.size(), i;
285 Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
286 aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl);
287 Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString;
288 for (int i = 0; i < aLength; i++) aColumn->Append((char*)theData[i].c_str());
290 aTable->SetRowData(theColumn, aColumn);
293 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
297 SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
298 aColumn->length(aLength);
299 for(i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str();
300 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
304 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetColumn(int theColumn)
306 std::vector<std::string> aVector;
309 Handle(TColStd_HSequenceOfExtendedString) aColumn;
310 aColumn = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetColumnData(theColumn);
311 aLength = aColumn->Length();
312 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aColumn->Value(i)).ToCString());
315 SALOMEDS::StringSeq_var aColumn = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumn(theColumn);
316 for(i = 0; i < aLength; i++) aVector.push_back(aColumn[i].in());
321 void SALOMEDS_AttributeTableOfString::PutValue(const std::string& theValue, int theRow, int theColumn)
326 Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->PutValue((char*)theValue.c_str(),
331 throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
335 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->PutValue(theValue.c_str(), theRow, theColumn);
339 bool SALOMEDS_AttributeTableOfString::HasValue(int theRow, int theColumn)
342 if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->HasValue(theRow, theColumn);
343 else ret = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->HasValue(theRow, theColumn);
347 std::string SALOMEDS_AttributeTableOfString::GetValue(int theRow, int theColumn)
353 TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetValue(theRow,
354 theColumn)).ToCString();
357 throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
361 aValue = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetValue(theRow, theColumn);
366 std::vector<int> SALOMEDS_AttributeTableOfString::GetRowSetIndices(int theRow)
368 std::vector<int> aVector;
371 Handle(TColStd_HSequenceOfInteger) aSet;
372 aSet = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetSetRowIndices(theRow);
373 aLength = aSet->Length();
374 for(i = 1; i<= aLength; i++) aVector.push_back(aSet->Value(i));
377 SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowSetIndices(theRow);
378 for(i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
383 void SALOMEDS_AttributeTableOfString::SetNbColumns(int theNbColumns)
385 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetNbColumns(theNbColumns);
386 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetNbColumns(theNbColumns);