[gdal-dev] CPLJSONDocument

Kurt Schwehr schwehr at gmail.com
Sat Jan 6 07:47:14 PST 2018


Andrew,

My take:

GDAL is a not a place to look for good modern C++ code.  And there is a of
old style C++ baked into the APIs, so drivers are particularly tough.

You can look for use of unique_ptr for some code that is heading in that
direction.

The other general problem with C++ code in GDAL is that it wasn't designed
with C++ testing in mind.  I've broken headers out of some of the drivers
so I can skip past the GDALOpen/Identify interfaces and test inside the
member functions.

You can look through
https://github.com/schwehr/gdal-autotest2/tree/master/cpp but most of that
code is pretty different as it is mostly tests.

GEOS is starting to modernize so you can look some there, but also isn't
particularly strong C++11 (yet)

A good place to start is with project style guides.  There are many around
with different takes.  The one I work to is:

https://google.github.io/styleguide/cppguide.html



On Sat, Jan 6, 2018 at 3:58 AM, Andrew C Aitchison <andrew at aitchison.me.uk>
wrote:

> On Fri, 5 Jan 2018, Kurt Schwehr wrote:
>
> * Passing char *psz yada all over the place in pure C++ code.  A const
>> std::string is usually not a noticeable expense and is a lot safer
>> * CPLString when std::string will do just fine.  And we can write free
>> functions to operate on strings.  I'm generally bothered by subclassing of
>> std::string as CPLString.  After reading large amounts of C++ code, I
>> think
>> it adds more confusion than it ever helps over having clean free
>> functions.  Interop and analysis with CPLString's is no fun.
>>
>> https://stackoverflow.com/questions/6006860/why-should-one-
>> not-derive-from-c-std-string-class
>>
>
> Can you point me to some good examples of good pure C++ code in GDAL
> - ideally driver code ? The driver tutorial
>   http://www.gdal.org/gdal_drivertut.html
> is full of pszFilename and other psz variables.
>
> When I taught myself C++ in 1992 std::string did not exist,
> and my gdal work is my only C++ practice since 1993.
> In my exploration of gdal code I have seen very little use of std::string
> and plenty of CPLString; it would be a great help to have good examples to
> copy.
>
> --
> Andrew C. Aitchison                                     Cambridge, UK
>                         andrew at aitchison.me.uk
>
>
>


-- 
--
http://schwehr.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20180106/58e15583/attachment.html>


More information about the gdal-dev mailing list