Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4265806
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:40:27+00:00 2026-05-21T06:40:27+00:00

Currently i’m developing most of my C++ Classes with the following structure and i

  • 0

Currently i’m developing most of my C++ Classes with the following structure and i was wondering if the community could give me some tips on how to improve my class design to make it more portable, friendly, and maintainable in the future.

#include <vector>
#include <iostream>

namespace CompanyName
{
    class Uri;
    class Regex;

    class String
    {
    public:
        String();
        String(const char*);
        String(const String&);

        virtual ~String();

        void trim();
        void erase();
        void remove(const int);
        void remove(const int, const size_t);

        void uppercase();
        void lowercase();

        bool is_null() const;
        bool is_empty() const;

        size_t length() const;

        void append(const String&);            

        bool compare(const String&) const;
        bool compare(const String&, const bool) const;

        void replace(const Regex&, const String&);

        std::vector<String> split(const Regex&) const;

        static const char* to_utf8(const String&);
        static const uint16_t* to_utf16(const String&);
        static const uint32_t* to_utf32(const String&);

        static String from_utf8(const char*);
        static String from_utf16(const uint16_t*);
        static String from_utf32(const uint32_t*);

        static String resource(const Uri&, const int);
        static String resource(const Uri&, const String&);

        String& operator=(String rhs);
        String& operator+(const String& rhs);
        String& operator+=(const String& rhs);

        bool operator==(const String&) const;
        bool operator!=(const String&) const;

        bool operator<(const String&) const;
        bool operator>(const String&) const;

        friend std::ostream& operator<<(std::ostream&, const String&);
        friend std::istream& operator>>(std::istream&, const String&);

        static const String null;
        static const String empty;

    protected:
        struct protected_pimpl;
        protected_pimpl* _protected_pimpl;

    private:
        struct private_pimpl;
        private_pimpl* _private_pimpl;
    };

    //we have to extract the content so as to not expose the UnicodeString.
    inline std::ostream& operator<<(std::ostream& stream, const CompanyName::String& rhs)
    {
        const char* value = String::to_utf8(rhs);
        stream << value;
        delete value;
        return stream;
    }

    inline std::istream& operator>>(std::istream& stream, const CompanyName::String& rhs)
    {
        const char* value = String::to_utf8(rhs);
        stream >> value;
        delete value;
        return stream;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:40:27+00:00Added an answer on May 21, 2026 at 6:40 am

    I would say that the first, best step would be to remove everything you don’t need.

    Consider the advice of Monoliths Unstrung: classes are more maintainable and ‘future-proof’ when they are pruned down to their primary concepts.

    For example: why does replace() need to be a member function? Or the to/from_utfX() functions?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I'm developing an app that functionality heavily relies upon retrieved JSON data. Most
Currently, I'm developing an application for Android OS. I would like to know the
Currently, I have: <html> <div class=yes1><span><img src=img></span></div> </html> <script> var x = ='yes1' var
Currently I am adding object by creating it like: type TRecord = class private
currently I'm developing an app for WP7 but came across a little problem with
Currently have the following expression: @[TMS_Dest] + \\ + @[TMS_Rename] + (DT_WSTR,4)DatePart(yyyy, GetDate()) +
Currently, most of the popular websites, like google, yahoo detect if the user connection
Currently, my MVC 3 app has a dependency on a static class that is
Currently I have the following Mapping in my Controller: @RequestMapping( value = /add.html, method
Currently, I use an abstract factory to allow the specification of a custom class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.