Skip to content

Commit d283a78

Browse files
author
Elisa Prana
committed
Add: functions to manipulate string attributes
1 parent 5684f6b commit d283a78

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

include/houio/HouGeo.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ namespace houio
3434
virtual void getPacking( std::vector<int> &packing )const;
3535
virtual int getNumElements()const;
3636
virtual std::string getString( int index )const;
37+
virtual std::string getUniqueString( int index )const;
38+
virtual int getStringIndex( int index )const;
39+
virtual std::vector<std::string> getUniqueStrings()const;
40+
virtual std::vector<int> getStringIndices()const;
41+
42+
43+
3744
virtual RawPointer::Ptr getRawPointer();
3845

3946
//int addV4f(math::V4f value);

src/HouGeo.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,38 @@ namespace houio
285285
return numElements++;
286286
}
287287

288+
std::string HouGeo::HouAttribute::getUniqueString( int index )const
289+
{
290+
if(strings.size() < index)
291+
throw std::runtime_error("HouGeo::getString Index is out of strings range.");
292+
return strings[index];
293+
}
294+
288295
std::string HouGeo::HouAttribute::getString( int index )const
289296
{
290297
if(stringsIdxs.size() < index)
291-
throw std::runtime_error("HouGeo::getString Index is out of stringsIdx range.");
292-
int string_index = stringsIdxs[index];
298+
throw std::runtime_error("HouGeo::getString Index is out of strings range.");
299+
const int string_index = stringsIdxs[index];
293300
return strings[string_index];
294301
}
295302

303+
int HouGeo::HouAttribute::getStringIndex( int index )const
304+
{
305+
if(stringsIdxs.size() < index)
306+
throw std::runtime_error("HouGeo::getStringIndex Index is out of stringsIdx range.");
307+
return stringsIdxs[index];
308+
}
309+
310+
std::vector<std::string> HouGeo::HouAttribute::getUniqueStrings()const
311+
{
312+
return strings;
313+
}
314+
315+
std::vector<int> HouGeo::HouAttribute::getStringIndices()const
316+
{
317+
return stringsIdxs;
318+
}
319+
296320

297321

298322

0 commit comments

Comments
 (0)