Skip to content

Commit

Permalink
Add: functions to manipulate string attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Elisa Prana committed Jul 20, 2020
1 parent 5684f6b commit d283a78
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
7 changes: 7 additions & 0 deletions include/houio/HouGeo.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ namespace houio
virtual void getPacking( std::vector<int> &packing )const;
virtual int getNumElements()const;
virtual std::string getString( int index )const;
virtual std::string getUniqueString( int index )const;
virtual int getStringIndex( int index )const;
virtual std::vector<std::string> getUniqueStrings()const;
virtual std::vector<int> getStringIndices()const;



virtual RawPointer::Ptr getRawPointer();

//int addV4f(math::V4f value);
Expand Down
28 changes: 26 additions & 2 deletions src/HouGeo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,38 @@ namespace houio
return numElements++;
}

std::string HouGeo::HouAttribute::getUniqueString( int index )const
{
if(strings.size() < index)
throw std::runtime_error("HouGeo::getString Index is out of strings range.");
return strings[index];
}

std::string HouGeo::HouAttribute::getString( int index )const
{
if(stringsIdxs.size() < index)
throw std::runtime_error("HouGeo::getString Index is out of stringsIdx range.");
int string_index = stringsIdxs[index];
throw std::runtime_error("HouGeo::getString Index is out of strings range.");
const int string_index = stringsIdxs[index];
return strings[string_index];
}

int HouGeo::HouAttribute::getStringIndex( int index )const
{
if(stringsIdxs.size() < index)
throw std::runtime_error("HouGeo::getStringIndex Index is out of stringsIdx range.");
return stringsIdxs[index];
}

std::vector<std::string> HouGeo::HouAttribute::getUniqueStrings()const
{
return strings;
}

std::vector<int> HouGeo::HouAttribute::getStringIndices()const
{
return stringsIdxs;
}




Expand Down

0 comments on commit d283a78

Please sign in to comment.