Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.