Loading [MathJax]/extensions/tex2jax.js
IODA
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
String_c.cpp
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020-2021 UCAR
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 /*! \addtogroup ioda_string
8  * @{
9  * \file String_c.cpp
10  * \brief @link ioda_string C bindings @endlink. Needed for reads.
11  */
12 
13 #include "ioda/C/String_c.h"
14 
15 #include <gsl/gsl-lite.hpp>
16 
17 extern "C" {
18 
20  C_TRY;
21  Expects(obj != nullptr);
22  Expects(obj->strings != nullptr);
23  for (size_t i = 0; i < obj->n; ++i) {
24  if (obj->strings[i] != nullptr) {
25  delete[] obj->strings[i];
26  }
27  }
28  delete[] obj->strings;
29  delete obj;
31 }
32 }
33 
34 /// @}
C bindings .
#define C_CATCH_AND_TERMINATE
Catch C++ exceptions before they go across code boundaries.
#define C_TRY
Goes with C_CATCH_AND_TERMINATE.
#define IODA_DL
A preprocessor tag that indicates that a symbol is to be exported/imported.
Definition: defs.h:110
IODA_DL void ioda_string_ret_t_destruct(struct ioda_string_ret_t *)
Deallocate a returned string object.
Definition: String_c.cpp:19
Return type when arrays of strings are encountered.
Definition: String_c.h:24
char ** strings
Definition: String_c.h:26