RAVE
|
Contains various utility functions that makes life easier when working with the rave framework. More...
#include "rave_utilities.h"
#include "rave_object.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include <string.h>
#include <stdio.h>
#include <ctype.h>
Functions | |
int | RaveUtilities_addLongAttributeToList (RaveObjectList_t *l, const char *name, long value) |
Adds a long attribute to an object list. | |
int | RaveUtilities_addDoubleAttributeToList (RaveObjectList_t *l, const char *name, double value) |
Adds a double attribute to an object list. | |
int | RaveUtilities_addStringAttributeToList (RaveObjectList_t *l, const char *name, const char *value) |
Adds a string attribute to an object list. | |
int | RaveUtilities_replaceLongAttributeInList (RaveObjectList_t *l, const char *name, long value) |
Replaces the content of a attribute in the object list. | |
int | RaveUtilities_replaceDoubleAttributeInList (RaveObjectList_t *l, const char *name, double value) |
Replaces the content of a attribute in the object list. | |
int | RaveUtilities_replaceStringAttributeInList (RaveObjectList_t *l, const char *name, const char *value) |
Replaces the content of a attribute in the object list. | |
void | RaveUtilities_removeAttributeFromList (RaveObjectList_t *l, const char *name) |
Removes the rave attribute with specified name from the list. | |
int | RaveUtilities_getRaveAttributeDoubleFromHash (RaveObjectHashTable_t *h, const char *name, double *v) |
Gets the double value from a rave attribute that resides in a hash table. | |
int | RaveUtilities_iswhitespace (char c) |
Returns if the character is a whitespace character or not, i.e. | |
char * | RaveUtilities_trimText (const char *str, int len) |
Trims the text from all leading and trailing whitespaces. | |
char * | RaveUtilities_toLower (const char *str, int len) |
Translates a string to lower case. | |
char * | RaveUtilities_toUpper (const char *str, int len) |
Translates a string to upper case. | |
RaveList_t * | RaveUtilities_getTrimmedTokens (const char *str, int c) |
Returns a list of tokens delimited by 'c'. | |
int | RaveUtilities_arrayContains (const char *arr[], const char *str, int casecmp) |
Checks if the array arr contains the string str. | |
int | RaveUtilities_isXmlSupported (void) |
Returns if xml support is activated or not since expat support is optional and ought to be tested. | |
int | RaveUtilities_isCFConventionSupported (void) |
Returns if CF convention IO support is activated or not. | |
int | RaveUtilities_isLegacyProjEnabled (void) |
Returns if legacy PROJ (PROJ.4 and PROJ 5) is enabled or not. | |
char * | RaveUtilities_handleSourceVersion (const char *source, RaveIO_ODIM_Version version) |
Handles the source value according to version. | |
int | RaveUtilities_isSourceValid (const char *source, RaveIO_ODIM_Version version) |
Verifies if the source is valid according to ODIM version rules. | |
Contains various utility functions that makes life easier when working with the rave framework.
int RaveUtilities_addDoubleAttributeToList | ( | RaveObjectList_t * | l, |
const char * | name, | ||
double | value ) |
Adds a double attribute to an object list.
[in] | l | - the list |
[in] | name | - the name of the attribute |
[in] | value | - the double |
int RaveUtilities_addLongAttributeToList | ( | RaveObjectList_t * | l, |
const char * | name, | ||
long | value ) |
Adds a long attribute to an object list.
[in] | l | - the list |
[in] | name | - the name of the attribute |
[in] | value | - the long |
int RaveUtilities_addStringAttributeToList | ( | RaveObjectList_t * | l, |
const char * | name, | ||
const char * | value ) |
Adds a string attribute to an object list.
[in] | l | - the list |
[in] | name | - the name of the attribute |
[in] | value | - the string |
int RaveUtilities_arrayContains | ( | const char * | arr[], |
const char * | str, | ||
int | casecmp ) |
Checks if the array arr contains the string str.
It is also possible to specify if string comparison should be done using case or not.
[in] | arr | - An array that has NULL at last entry |
[in] | str | - the string to check for |
[in] | casecmp | - If case should be used or not. |
int RaveUtilities_getRaveAttributeDoubleFromHash | ( | RaveObjectHashTable_t * | h, |
const char * | name, | ||
double * | v ) |
Gets the double value from a rave attribute that resides in a hash table.
[in] | h | - the hash table |
[in] | name | - the name |
[in,out] | v | - the value |
RaveList_t * RaveUtilities_getTrimmedTokens | ( | const char * | str, |
int | c ) |
Returns a list of tokens delimited by 'c'.
The tokens will be trimmed from any leading and trailing whitespaces.
[in] | str | - the string to tokenize |
[in] | c | - the delimiter |
char * RaveUtilities_handleSourceVersion | ( | const char * | source, |
RaveIO_ODIM_Version | version ) |
Handles the source value according to version.
For example, if version < 2.3, then WIGOS will be removed.
[in] | source | - source to be verified |
[in] | version | - what version we want to validate against. |
int RaveUtilities_isCFConventionSupported | ( | void | ) |
Returns if CF convention IO support is activated or not.
int RaveUtilities_isLegacyProjEnabled | ( | void | ) |
Returns if legacy PROJ (PROJ.4 and PROJ 5) is enabled or not.
int RaveUtilities_isSourceValid | ( | const char * | source, |
RaveIO_ODIM_Version | version ) |
Verifies if the source is valid according to ODIM version rules.
Currently the only restriction is for version >= 2.4 which says that either NOD or ORG must exist in the file depending on object type. We will not care about object type and only check if one or both of NOD or ORG exists.
[in] | source | - the source to check |
[in] | version | - the version we are testing against. |
int RaveUtilities_iswhitespace | ( | char | c | ) |
Returns if the character is a whitespace character or not, i.e.
' ', '\t', '\r' or '
'
[in] | c | - the character to check |
int RaveUtilities_isXmlSupported | ( | void | ) |
Returns if xml support is activated or not since expat support is optional and ought to be tested.
void RaveUtilities_removeAttributeFromList | ( | RaveObjectList_t * | l, |
const char * | name ) |
Removes the rave attribute with specified name from the list.
[in] | l | - the list |
[in] | name | - the name |
int RaveUtilities_replaceDoubleAttributeInList | ( | RaveObjectList_t * | l, |
const char * | name, | ||
double | value ) |
Replaces the content of a attribute in the object list.
If the attribute does not exist a new one will be created.
[in] | l | - the list |
[in] | name | - the name of the attribute |
[in] | value | - the double |
int RaveUtilities_replaceLongAttributeInList | ( | RaveObjectList_t * | l, |
const char * | name, | ||
long | value ) |
Replaces the content of a attribute in the object list.
If the attribute does not exist a new one will be created.
[in] | l | - the list |
[in] | name | - the name of the attribute |
[in] | value | - the long |
int RaveUtilities_replaceStringAttributeInList | ( | RaveObjectList_t * | l, |
const char * | name, | ||
const char * | value ) |
Replaces the content of a attribute in the object list.
If the attribute does not exist a new one will be created.
[in] | l | - the list |
[in] | name | - the name of the attribute |
[in] | value | - the string |
char * RaveUtilities_toLower | ( | const char * | str, |
int | len ) |
Translates a string to lower case.
[in] | str | - the string to convert |
[in] | len | - the length of the string to convert |
char * RaveUtilities_toUpper | ( | const char * | str, |
int | len ) |
Translates a string to upper case.
[in] | str | - the string to convert |
[in] | len | - the length of the string to convert |
char * RaveUtilities_trimText | ( | const char * | str, |
int | len ) |
Trims the text from all leading and trailing whitespaces.
[in] | str | - the string to trim |
[in] | len | - the length of the string to trim |