Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I define a CPLString this way:

CPLString osString;

And I want to check if osString is not empty, what would be the best way?

My bet:

if (osString.c_str() == NULL)

But I find it a little rusty... Is there any other better way?

Many thanks in advance

share|improve this question
up vote 1 down vote accepted

gdal CPLString is a convenient class for std::string

class CPL_DLL CPLString : public gdal_std_string

and gdal_std_string is a typedef for std::string or MSVC string class

00213 # define gdal_std_string string
00214 #else
00215 # define gdal_std_string std::string
00216 #endif 

Source:GDAL API docs

so basically CPLString can be checked for emptiness using std::string::empty()

in your case:

osString.empty() returns True if its empty.

share|improve this answer
absolutely right. Thanks! – jorgeas80 May 19 '13 at 12:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.