Current specifications:
String data in the form of wide or narrow character arrays records the functionality for a class that provides data statistics and modifies data.
The requirement is that it can be maintained for a long time.
So my first approach is to require raw char arrays to be split into strings earlier, and then just specify the template class:
template<class T> class MyString { private: T _data; public: MyString(T& input) { _data = input; }; size_t doSomeWork() {
or static member functions:
class StringTools { public: static size_t doWork(const char*) {} static size_t doWork(const wchar_t*) {} };
or use a strategy template:
class MyString { protected: MyStringBase(); public: virtual ~MyStringBase(); virtual size_t doWork() = 0; }; class MyStringCharArray : public MyString { protected: char* _data; public: MyStringCharArray(const char* input) : MyString() { } virtual size_t doWork() {...}; };
and then in the future, if for some god-forgotten reason I switch to BStr, then it will only be necessary for the first two lines of code to be changed in addition to the newly written derived class.
I think that if I write a wrapper class, as in 1 and 3, it will become a lot more difficult thing, and any encapsulation will be broken, since I must allow access to the base one.
but if I create a class with only static functions, then everything that it does mimics a namespace that would be better served by some non-member functions, different from each other, encapsulated under the namespace "stringtools". But then I will still spread the mess of massive character arrays throughout the application, and additional verification should be performed, etc., And the specification is explicitly set for the class.
So what will be the cleanest and most convenient approach?
Rgds