Browse Source

Added shiftLeft() and shiftRight()

release/0.19
JustinAJ 11 years ago
parent
commit
952ac5c00a
  1. 16
      Jupiter/Reference_String.h
  2. 17
      Jupiter/Reference_String_Imp.h

16
Jupiter/Reference_String.h

@ -69,6 +69,22 @@ namespace Jupiter
*/ */
virtual size_t truncate(size_t n); virtual size_t truncate(size_t n);
/**
* @brief Shifts the string pointer to the left.
*
* @param length Number of elements to shift
* @return Number of elements shifted to the left.
*/
size_t shiftLeft(size_t length);
/**
* @brief Shifts the string pointer to the right.
*
* @param length Number of elements to shift
* @return Number of elements shifted.
*/
size_t shiftRight(size_t length);
/** /**
* @brief Sets the reference to point to an input string. * @brief Sets the reference to point to an input string.
* *

17
Jupiter/Reference_String_Imp.h

@ -88,6 +88,23 @@ template<typename T> size_t Jupiter::Reference_String<T>::truncate(size_t n)
return (Jupiter::Reference_String<T>::length -= n); return (Jupiter::Reference_String<T>::length -= n);
} }
// shift
template<typename T> size_t Jupiter::Reference_String<T>::shiftLeft(size_t len)
{
Jupiter::String_Type<T>::str -= len;
Jupiter::String_Type<T>::length += len;
return len;
}
template<typename T> size_t Jupiter::Reference_String<T>::shiftRight(size_t len)
{
if (len > Jupiter::String_Type<T>::length) len = Jupiter::String_Type<T>::length;
Jupiter::String_Type<T>::str += len;
Jupiter::String_Type<T>::length -= len;
return len;
}
// set // set
template<typename T> size_t Jupiter::Reference_String<T>::set(const Jupiter::Readable_String<T> &in) template<typename T> size_t Jupiter::Reference_String<T>::set(const Jupiter::Readable_String<T> &in)

Loading…
Cancel
Save