[gdal-dev] What is the best way to test if a CPLString is not empty?

Frank Warmerdam warmerdam at pobox.com
Thu May 16 11:07:28 PDT 2013


Jorge,

I don't believe oString.c_str() will ever be NULL.  You can use the
std::string empty() method to test if a string is empty (zero length).

  http://www.cplusplus.com/reference/string/string/empty/

CPLStrings have no equivelient to a NULL distinct from being a zero length
string.

Best regards,
Frank

On Thu, May 16, 2013 at 10:17 AM, Jorge Arévalo
<jorgearevalo at libregis.org>wrote:

> 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
>
> --
> Jorge Arevalo
> Freelance developer
>
> http://www.krop.com/jorgearevalo
> http://about.me/jorgeas80
>
> Enviado con Sparrow (http://www.sparrowmailapp.com/?sig)
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Software Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130516/fc250408/attachment.html>


More information about the gdal-dev mailing list