mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-21 08:39:46 +08:00
d538cf38c2
The primary fix is to improve CMake build support. Specific changes include: * CMake: Provide a better soln to locating the AWS SDK libraries; the new way is the preferred method as described in the aws-cpp-sdk documentation. * CMake (and Automake): allow -DENABLE_S3_SDK (default off) to suppress looking for AWS libraries. * CMake: add the complete set of nczarr tests * CMake: add EXTERNL as needed to various .h files. * Improve support for windows drive letters in paths. * Add nczarr and s3 flags to nc-config * For VisualStudio X nczarr, cleanup the NAN+INFINITY handling * Convert _MSC_VER -> _WIN32 and vice versa as needed * NCZarr - support multiple platform paths including windows, cygwin. mingw, etc. * NCZarr - sort the test outputs because different platforms produce directory contents in different orders. One big change concerns netcdf-c/CMakeLists.txt and netcdf-c/configure.ac. In the current versions, it was the case that --disable-hdf5 disabled netcdf-4 (libsrc4). With nczarr, this can no longer be the case because nczarr requires libsrc4 even if libhdf5 is disabled. So, I modified the above files to move the format options (HDF5, NCZarr, HDF4, etc) to a single place near the front of the files. Now it is the case that: * Enabling any of the formats that require libsrc4 also does an implicit --enable-netcdf4. * --disable-netcdf4 | --disable-netcdf-4 now becomes and alias for --disable-hdf5. There are probably some bugs in this change in terms of dependencies between format options. Problems: * CMake S3 support is still not working for Visual Studio * A recent issue points out that there is work to do on handling UTF8 filenames, but that will be addressed in a separate fix. Notes: * Consider converting all of our includes/.h files to use EXTERNL
90 lines
2.5 KiB
C
90 lines
2.5 KiB
C
/* Copyright 2018, UCAR/Unidata.
|
|
See the COPYRIGHT file for more information.
|
|
*/
|
|
|
|
#ifndef NCJSON_H
|
|
#define NCJSON_H 1
|
|
|
|
#include "ncexternl.h"
|
|
|
|
/* Json object sorts */
|
|
#define NCJ_UNDEF 0
|
|
#define NCJ_STRING 1
|
|
#define NCJ_INT 2
|
|
#define NCJ_DOUBLE 3
|
|
#define NCJ_BOOLEAN 4
|
|
#define NCJ_DICT 5
|
|
#define NCJ_ARRAY 6
|
|
#define NCJ_NULL 7
|
|
|
|
/* Don't bother with unions: define
|
|
a struct to store primitive values
|
|
as unquoted strings. Sort will
|
|
provide more info.
|
|
|
|
Also, this does not use a true hashmap
|
|
but rather an envv style list where name
|
|
and value alternate. This works under
|
|
the assumption that we are generally
|
|
iterating over the Dict rather than
|
|
probing it.
|
|
|
|
*/
|
|
typedef struct NCjson {
|
|
int sort;
|
|
char* value;
|
|
NClist* contents; /* For array|dict */
|
|
} NCjson;
|
|
|
|
#define NCJF_MULTILINE 1
|
|
|
|
/* Parse */
|
|
EXTERNL int NCJparse(const char* text, unsigned flags, NCjson** jsonp);
|
|
|
|
/* Build */
|
|
EXTERNL int NCJnew(int sort, NCjson** object);
|
|
|
|
/* Convert a nul terminated string value to an NCjson object */
|
|
EXTERNL int NCJnewstring(int sort, const char* value, NCjson** jsonp);
|
|
|
|
/* Convert a counted string value to an NCjson object (+ nul term)*/
|
|
EXTERNL int NCJnewstringn(int sort, size_t len, const char* value, NCjson** jsonp);
|
|
|
|
/* Insert key-value pair into a dict object.
|
|
key will be strdup'd.
|
|
*/
|
|
EXTERNL int NCJinsert(NCjson* object, char* key, NCjson* value);
|
|
|
|
/* Insert a string value into a json Dict|Array */
|
|
EXTERNL int NCJaddstring(NCjson* dictarray, int sort, const char* value);
|
|
|
|
/* Get ith pair from dict */
|
|
EXTERNL int NCJdictith(NCjson* object, size_t i, const char** keyp, NCjson** valuep);
|
|
|
|
/* Get value for key from dict */
|
|
EXTERNL int NCJdictget(NCjson* object, const char* key, NCjson** valuep);
|
|
|
|
/* Append value to an array or dict object. */
|
|
EXTERNL int NCJappend(NCjson* object, NCjson* value);
|
|
|
|
/* Get ith element from array */
|
|
EXTERNL int NCJarrayith(NCjson* object, size_t i, NCjson** valuep);
|
|
|
|
/* Unparser to convert NCjson object to text in buffer */
|
|
EXTERNL int NCJunparse(const NCjson* json, int flags, char** textp);
|
|
|
|
/* Utilities */
|
|
EXTERNL void NCJreclaim(NCjson*);
|
|
EXTERNL int NCJclone(NCjson* json, NCjson** clonep); /* deep clone */
|
|
|
|
/* dump NCjson* object */
|
|
EXTERNL void NCJdump(const NCjson* json, int flags);
|
|
|
|
/* Macro defined functions */
|
|
#define NCJlength(json) \
|
|
((json)->sort == NCJ_DICT ? (nclistlength((json)->contents)/2) \
|
|
: ((json)->sort == NCJ_ARRAY ? (nclistlength((json)->contents)) \
|
|
: 1))
|
|
|
|
#endif /*NCJSON_H*/
|