Skip to content

Commit

Permalink
Merge pull request #1572 from Expensify/dsilva_addingSetAuxiliarMethods
Browse files Browse the repository at this point in the history
Adding SParseIntegerSet method
  • Loading branch information
danieldoglas authored Sep 25, 2023
2 parents d55f217 + b27bc73 commit 0a5f813
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libstuff/libstuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,16 @@ list<int64_t> SParseIntegerList(const string& value, char separator) {
return valueList;
}

// --------------------------------------------------------------------------
set<int64_t> SParseIntegerSet(const string& value, char separator) {
set<int64_t> valueSet;
list<string> strings = SParseList(value, separator);
for (const string& str : strings) {
valueSet.insert(SToInt64(str));
}
return valueSet;
}

// --------------------------------------------------------------------------
bool SParseList(const char* ptr, list<string>& valueList, char separator) {
// Clear the input
Expand Down
1 change: 1 addition & 0 deletions libstuff/libstuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ string SEncodeURIComponent(const string& value);
// --------------------------------------------------------------------------
// List management
list<int64_t> SParseIntegerList(const string& value, char separator = ',');
set<int64_t> SParseIntegerSet(const string& value, char separator = ',');
bool SParseList(const char* value, list<string>& valueList, char separator = ',');
bool SParseList(const string& value, list<string>& valueList, char separator = ',');
list<string> SParseList(const string& value, char separator = ',');
Expand Down

0 comments on commit 0a5f813

Please sign in to comment.