Jump to content
  • Advertisement
Sign in to follow this  
wood_brian

String classes

This topic is 2538 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
In my homegrown projects I commonly use two of my own in addition to std::(w)string:

ref_string: The buffer is immutable and reference-counted. Copying is no-throw, so it can be safely used as a member variable in objects thrown as exceptions.

string_literal: lightweight wrapper around string literal with overloaded comparison operators. Used inside my test library to internally wrap __FILE__, __DATE__, __TIME__, the names of tests, etc.

In the past I've also used any number of string classes that came with other frameworks e.g. QString from Qt, Glib::ustring from glibmm, etc. They are at least somewhat knowledgeable of Unicode.

Another type of string I've seen used is one that interns the buffers in order to allow comparisons to be made quicker (only the pointers need be compared).

To be honest, I find the use of std::string as anything but a container of 'char' somewhat cumbersome. Often that's all that's needed, but as soon as you start having to do string manipulation, it quickly becomes a pain.

Share this post


Link to post
Share on other sites
I just stick with std::string and char* at the moment, but I'm considering adding a HashString that combines a std::string with a hash value for fast lookups etc. Compile time hashing of literals would be fabulous, but the preprocessor can't do it and I don't want to integrate it into the build.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!