diff --git a/Jupiter/CString.h b/Jupiter/CString.h index b562539..3accc77 100644 --- a/Jupiter/CString.h +++ b/Jupiter/CString.h @@ -226,6 +226,7 @@ namespace Jupiter CString_Type(const CString_Type &in) : CString_Type((Readable_String &)in) {} CString_Type(const Readable_String &in); CString_Type(const std::basic_string &in); + CString_Type(const T *in, size_t len); CString_Type(const T *in); protected: @@ -378,6 +379,7 @@ namespace Jupiter CString_Loose(const CString_Loose &in); CString_Loose(const Readable_String &in); CString_Loose(const std::basic_string &in); + CString_Loose(const T *in, size_t len); CString_Loose(const T *in); static const Jupiter::CString_Loose empty; /** Empty instantation of CString_Loose */ diff --git a/Jupiter/CString_Imp.h b/Jupiter/CString_Imp.h index 3e1e70c..ce616e6 100644 --- a/Jupiter/CString_Imp.h +++ b/Jupiter/CString_Imp.h @@ -59,22 +59,21 @@ template Jupiter::CString_Type::CString_Type(Jupiter::CString_Typ { } -template Jupiter::CString_Type::CString_Type(const Jupiter::Readable_String &in) : Jupiter::CString_Type::CString_Type(in.size()) +template Jupiter::CString_Type::CString_Type(const Jupiter::Readable_String &in) : Jupiter::CString_Type::CString_Type(in.ptr(), in.size()) { - while (Jupiter::String_Type::length < in.size() && in.get(Jupiter::String_Type::length) != 0) - { - Jupiter::String_Type::str[Jupiter::String_Type::length] = in.get(Jupiter::String_Type::length); - Jupiter::String_Type::length++; - } - Jupiter::String_Type::str[Jupiter::String_Type::length] = 0; } -template Jupiter::CString_Type::CString_Type(const std::basic_string &in) : Jupiter::CString_Type::CString_Type(in.size()) +template Jupiter::CString_Type::CString_Type(const std::basic_string &in) : Jupiter::CString_Type::CString_Type(in.data(), in.size()) { - while (Jupiter::String_Type::length < in.size() && in.at(Jupiter::String_Type::length) != 0) +} + +template Jupiter::CString_Type::CString_Type(const T *in, size_t len) : Jupiter::CString_Type::CString_Type(len) +{ + while (Jupiter::String_Type::length != len) { - Jupiter::String_Type::str[Jupiter::String_Type::length] = in.at(Jupiter::String_Type::length); + if ((Jupiter::String_Type::str[Jupiter::String_Type::length] = *in) == 0) return; Jupiter::String_Type::length++; + in++; } Jupiter::String_Type::str[Jupiter::String_Type::length] = 0; } @@ -408,21 +407,19 @@ template Jupiter::CString_Loose::CString_Loose(const Jupiter::CSt Jupiter::String_Type::length = in.length; } -template Jupiter::CString_Loose::CString_Loose(const Jupiter::Readable_String &in) : Jupiter::CString_Loose::CString_Loose(in.size()) +template Jupiter::CString_Loose::CString_Loose(const Jupiter::Readable_String &in) : Jupiter::CString_Loose::CString_Loose(in.ptr(), in.size()) { - while (Jupiter::String_Type::length < in.size() && in.get(Jupiter::String_Type::length) != 0) - { - Jupiter::String_Type::str[Jupiter::String_Type::length] = in.get(Jupiter::String_Type::length); - Jupiter::String_Type::length++; - } - Jupiter::String_Type::str[Jupiter::String_Type::length] = 0; } -template Jupiter::CString_Loose::CString_Loose(const std::basic_string &in) : Jupiter::CString_Loose::CString_Loose(in.size()) +template Jupiter::CString_Loose::CString_Loose(const std::basic_string &in) : Jupiter::CString_Loose::CString_Loose(in.data(), in.size()) { - while (Jupiter::String_Type::length < in.size() && in.at(Jupiter::String_Type::length) != 0) +} + +template Jupiter::CString_Loose::CString_Loose(const T *in, size_t len) : Jupiter::CString_Loose::CString_Loose(len) +{ + while (Jupiter::String_Type::length != len) { - Jupiter::String_Type::str[Jupiter::String_Type::length] = in.at(Jupiter::String_Type::length); + if ((Jupiter::String_Type::str[Jupiter::String_Type::length] = *in) == 0) return; Jupiter::String_Type::length++; } Jupiter::String_Type::str[Jupiter::String_Type::length] = 0; diff --git a/Jupiter/String.h b/Jupiter/String.h index 0b82a60..29d07d8 100644 --- a/Jupiter/String.h +++ b/Jupiter/String.h @@ -189,6 +189,7 @@ namespace Jupiter String_Strict(const String_Strict &in) : String_Strict((Readable_String &)in) {} String_Strict(const Readable_String &in); String_Strict(const std::basic_string &in); + String_Strict(const T *in, size_t len); String_Strict(const T *in); protected: @@ -349,6 +350,7 @@ namespace Jupiter String_Loose(const String_Loose &in); String_Loose(const Readable_String &in); String_Loose(const std::basic_string &in); + String_Loose(const T *in, size_t len); String_Loose(const T *in); static const Jupiter::String_Loose empty; /** Empty instantation of String_Loose */ diff --git a/Jupiter/String_Imp.h b/Jupiter/String_Imp.h index 0354a5b..11d5583 100644 --- a/Jupiter/String_Imp.h +++ b/Jupiter/String_Imp.h @@ -57,21 +57,21 @@ template Jupiter::String_Strict::String_Strict(Jupiter::String_St { } -template Jupiter::String_Strict::String_Strict(const Jupiter::Readable_String &in) : Jupiter::String_Strict::String_Strict(in.size()) +template Jupiter::String_Strict::String_Strict(const Jupiter::Readable_String &in) : Jupiter::String_Strict::String_Strict(in.ptr(), in.size()) +{ +} + +template Jupiter::String_Strict::String_Strict(const std::basic_string &in) : Jupiter::String_Strict::String_Strict(in.data(), in.size()) { - while (Jupiter::String_Type::length < in.size()) - { - Jupiter::String_Type::str[Jupiter::String_Type::length] = in.get(Jupiter::String_Type::length); - Jupiter::String_Type::length++; - } } -template Jupiter::String_Strict::String_Strict(const std::basic_string &in) : Jupiter::String_Strict::String_Strict(in.size()) +template Jupiter::String_Strict::String_Strict(const T *in, size_t len) : Jupiter::String_Strict::String_Strict(len) { - while (Jupiter::String_Type::length < in.size()) + while (Jupiter::String_Type::length != len) { - Jupiter::String_Type::str[Jupiter::String_Type::length] = in.at(Jupiter::String_Type::length); + Jupiter::String_Type::str[Jupiter::String_Type::length] = *in; Jupiter::String_Type::length++; + in++; } } @@ -275,21 +275,21 @@ template Jupiter::String_Loose::String_Loose(const Jupiter::Strin Jupiter::String_Type::str[Jupiter::String_Type::length] = in.get(Jupiter::String_Type::length); } -template Jupiter::String_Loose::String_Loose(const Jupiter::Readable_String &in) : Jupiter::String_Loose::String_Loose(in.size()) +template Jupiter::String_Loose::String_Loose(const Jupiter::Readable_String &in) : Jupiter::String_Loose::String_Loose(in.ptr(), in.size()) +{ +} + +template Jupiter::String_Loose::String_Loose(const std::basic_string &in) : Jupiter::String_Loose::String_Loose(in.data(), in.size()) { - while (Jupiter::String_Type::length < in.size()) - { - Jupiter::String_Type::str[Jupiter::String_Type::length] = in.get(Jupiter::String_Type::length); - Jupiter::String_Type::length++; - } } -template Jupiter::String_Loose::String_Loose(const std::basic_string &in) : Jupiter::String_Loose::String_Loose(in.size()) +template Jupiter::String_Loose::String_Loose(const T *in, size_t len) : Jupiter::String_Loose::String_Loose(len) { - while (Jupiter::String_Type::length < in.size()) + while (Jupiter::String_Type::length != len) { - Jupiter::String_Type::str[Jupiter::String_Type::length] = in.at(Jupiter::String_Type::length); + Jupiter::String_Type::str[Jupiter::String_Type::length] = *in; Jupiter::String_Type::length++; + in++; } }