Browse Source

added span() function

release/0.19
JustinAJ 10 years ago
parent
commit
91874cf9a6
  1. 9
      Jupiter/Readable_String.h
  2. 16
      Jupiter/Readable_String_Imp.h

9
Jupiter/Readable_String.h

@ -81,6 +81,15 @@ namespace Jupiter
size_t find(const T &value, size_t index = 0) const;
size_t find(const Readable_String<T> &in) const;
/**
* @brief Returns the number of elements of the string which match the input string.
*
* @param in Character set to match against.
* @return Number of elements at the start of the string that match the character set.
*/
size_t span(const Readable_String<T> &in) const;
size_t span(const T *str) const;
/**
* @brief Compares another string against the String.
*

16
Jupiter/Readable_String_Imp.h

@ -68,6 +68,22 @@ template<typename T> size_t Jupiter::Readable_String<T>::find(const Jupiter::Rea
return Jupiter::INVALID_INDEX;
}
// span()
template<typename T> size_t Jupiter::Readable_String<T>::span(const Jupiter::Readable_String<T> &in) const
{
size_t index = 0;
while (in.contains(this->get(index))) index++;
return index;
}
template<typename T> size_t Jupiter::Readable_String<T>::span(const T *in) const
{
size_t index = 0;
while (containsSymbol(in, this->get(index))) index++;
return index;
}
// compare()
template<typename T> int Jupiter::Readable_String<T>::compare(const Jupiter::Readable_String<T> &in) const

Loading…
Cancel
Save