|
@ -1,5 +1,5 @@ |
|
|
/**
|
|
|
/**
|
|
|
* Copyright (C) 2014 Justin James. |
|
|
* Copyright (C) 2014-2015 Justin James. |
|
|
* |
|
|
* |
|
|
* This license must be preserved. |
|
|
* This license must be preserved. |
|
|
* Any applications, libraries, or code which make any use of any |
|
|
* Any applications, libraries, or code which make any use of any |
|
@ -132,31 +132,93 @@ template<typename T> bool Jupiter::String_Type<T>::remove(const T &value) |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(const Jupiter::Readable_String<T> &in) |
|
|
// set
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(size_t index, const T &in) |
|
|
{ |
|
|
{ |
|
|
this->setBufferSizeNoCopy(in.size()); |
|
|
if (index == this->size()) |
|
|
for (Jupiter::String_Type<T>::length = 0; Jupiter::String_Type<T>::length < in.size() != 0; Jupiter::String_Type<T>::length++) |
|
|
return this->concat(in); |
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length] = in.get(Jupiter::String_Type<T>::length); |
|
|
|
|
|
|
|
|
if (index > this->size()) |
|
|
|
|
|
{ |
|
|
|
|
|
this->setBufferSize(index + 1); |
|
|
|
|
|
while (Jupiter::String_Type<T>::length != index) |
|
|
|
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length++] = 0; |
|
|
|
|
|
Jupiter::String_Type<T>::length++; |
|
|
|
|
|
} |
|
|
|
|
|
Jupiter::String_Type<T>::str[index] = in; |
|
|
return Jupiter::String_Type<T>::length; |
|
|
return Jupiter::String_Type<T>::length; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(const std::basic_string<T> &in) |
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(size_t index, const T *in, size_t inSize) |
|
|
{ |
|
|
{ |
|
|
this->setBufferSizeNoCopy(in.size()); |
|
|
if (index == this->size()) |
|
|
for (Jupiter::String_Type<T>::length = 0; Jupiter::String_Type<T>::length < in.size(); Jupiter::String_Type<T>::length++) |
|
|
return this->concat(in); |
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length] = in.at(Jupiter::String_Type<T>::length); |
|
|
|
|
|
|
|
|
if (index > this->size()) |
|
|
|
|
|
{ |
|
|
|
|
|
this->setBufferSize(index + inSize); |
|
|
|
|
|
while (Jupiter::String_Type<T>::length != index) |
|
|
|
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length++] = 0; |
|
|
|
|
|
index = 0; |
|
|
|
|
|
while (index != inSize) |
|
|
|
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length++] = in[index]; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
index += inSize; |
|
|
|
|
|
if (index > Jupiter::String_Type<T>::length) |
|
|
|
|
|
{ |
|
|
|
|
|
this->setBufferSize(index); |
|
|
|
|
|
Jupiter::String_Type<T>::length = index; |
|
|
|
|
|
} |
|
|
|
|
|
while (inSize != 0) |
|
|
|
|
|
Jupiter::String_Type<T>::str[--index] = in[--inSize]; |
|
|
|
|
|
} |
|
|
return Jupiter::String_Type<T>::length; |
|
|
return Jupiter::String_Type<T>::length; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(const T *in) |
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(size_t index, const Jupiter::Readable_String<T> &in) |
|
|
{ |
|
|
{ |
|
|
size_t nLen = Jupiter::strlen<T>(in); |
|
|
return this->set(index, in.ptr(), in.size()); |
|
|
this->setBufferSizeNoCopy(nLen); |
|
|
} |
|
|
for (Jupiter::String_Type<T>::length = 0; *in != 0; Jupiter::String_Type<T>::length++, in++) Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length] = *in; |
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(size_t index, const std::basic_string<T> &in) |
|
|
|
|
|
{ |
|
|
|
|
|
return this->set(index, in.c_str(), in.size()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(size_t index, const T *in) |
|
|
|
|
|
{ |
|
|
|
|
|
return this->set(index, in, Jupiter::strlen<T>(in)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(const T *in, size_t inSize) |
|
|
|
|
|
{ |
|
|
|
|
|
this->setBufferSizeNoCopy(inSize); |
|
|
|
|
|
Jupiter::String_Type<T>::length = inSize; |
|
|
|
|
|
while (inSize-- != 0) |
|
|
|
|
|
*Jupiter::String_Type<T>::str++ = *in++; |
|
|
|
|
|
Jupiter::String_Type<T>::str -= Jupiter::String_Type<T>::length; |
|
|
return Jupiter::String_Type<T>::length; |
|
|
return Jupiter::String_Type<T>::length; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(const T in) |
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(const Jupiter::Readable_String<T> &in) |
|
|
|
|
|
{ |
|
|
|
|
|
return this->set(in.ptr(), in.size()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(const std::basic_string<T> &in) |
|
|
|
|
|
{ |
|
|
|
|
|
return this->set(in.c_str(), in.size()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(const T *in) |
|
|
|
|
|
{ |
|
|
|
|
|
return this->set(in, Jupiter::strlen<T>(in)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(const T &in) |
|
|
{ |
|
|
{ |
|
|
this->setBufferSizeNoCopy(1); |
|
|
this->setBufferSizeNoCopy(1); |
|
|
*Jupiter::String_Type<T>::str = in; |
|
|
*Jupiter::String_Type<T>::str = in; |
|
@ -373,48 +435,30 @@ template<typename T> size_t Jupiter::String_Type<T>::replace(const Jupiter::Read |
|
|
|
|
|
|
|
|
// concat
|
|
|
// concat
|
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::concat(const Jupiter::Readable_String<T> &in) |
|
|
template<typename T> size_t Jupiter::String_Type<T>::concat(const T *in, size_t inSize) |
|
|
{ |
|
|
{ |
|
|
size_t nSize = Jupiter::String_Type<T>::length + in.size(); |
|
|
this->setBufferSize(Jupiter::String_Type<T>::length + inSize); |
|
|
const T *inData = in.ptr(); |
|
|
while (inSize-- != 0) |
|
|
this->setBufferSize(nSize); |
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length++] = *in++; |
|
|
while (Jupiter::String_Type<T>::length != nSize) |
|
|
|
|
|
{ |
|
|
|
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length] = *inData; |
|
|
|
|
|
Jupiter::String_Type<T>::length++; |
|
|
|
|
|
inData++; |
|
|
|
|
|
} |
|
|
|
|
|
return Jupiter::String_Type<T>::length; |
|
|
return Jupiter::String_Type<T>::length; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::concat(const Jupiter::Readable_String<T> &in) |
|
|
|
|
|
{ |
|
|
|
|
|
return this->concat(in.ptr(), in.size()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::concat(const std::basic_string<T> &in) |
|
|
template<typename T> size_t Jupiter::String_Type<T>::concat(const std::basic_string<T> &in) |
|
|
{ |
|
|
{ |
|
|
size_t nSize = Jupiter::String_Type<T>::length + in.size(); |
|
|
return this->concat(in.c_str(), in.size()); |
|
|
const T *inData = in.data(); |
|
|
|
|
|
this->setBufferSize(nSize); |
|
|
|
|
|
while (Jupiter::String_Type<T>::length != nSize) |
|
|
|
|
|
{ |
|
|
|
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length] = *inData; |
|
|
|
|
|
Jupiter::String_Type<T>::length++; |
|
|
|
|
|
inData++; |
|
|
|
|
|
} |
|
|
|
|
|
return Jupiter::String_Type<T>::length; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::concat(const T *in) |
|
|
template<typename T> size_t Jupiter::String_Type<T>::concat(const T *in) |
|
|
{ |
|
|
{ |
|
|
size_t nSize = Jupiter::String_Type<T>::length + Jupiter::strlen<T>(in); |
|
|
return this->concat(in, Jupiter::strlen<T>(in)); |
|
|
this->setBufferSize(nSize); |
|
|
|
|
|
while (*in != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length] = *in; |
|
|
|
|
|
Jupiter::String_Type<T>::length++; |
|
|
|
|
|
in++; |
|
|
|
|
|
} |
|
|
|
|
|
return Jupiter::String_Type<T>::length; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::concat(const T c) |
|
|
template<typename T> size_t Jupiter::String_Type<T>::concat(const T &c) |
|
|
{ |
|
|
{ |
|
|
this->setBufferSize(Jupiter::String_Type<T>::length + 1); |
|
|
this->setBufferSize(Jupiter::String_Type<T>::length + 1); |
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length] = c; |
|
|
Jupiter::String_Type<T>::str[Jupiter::String_Type<T>::length] = c; |
|
|