ritsuko
Helper utilities for ArtifactDB C++ code
Loading...
Searching...
No Matches
ritsuko Namespace Reference

Helper functions for ArtifactDB parsing and validation. More...

Namespaces

namespace  cvls
 Utilities for reading and validating compressed VLS arrays.
 
namespace  hdf5
 Utilities for reading and validating HDF5 files.
 

Classes

struct  Version
 Version number. More...
 

Functions

bool is_date_prefix (const char *ptr)
 
bool is_date (const char *ptr, size_t len)
 
bool is_rfc3339_suffix (const char *ptr, size_t len)
 
bool is_rfc3339 (const char *ptr, size_t len)
 
Version parse_version_string (const char *version_string, size_t size, bool skip_patch=false)
 

Detailed Description

Helper functions for ArtifactDB parsing and validation.

Function Documentation

◆ is_date()

bool ritsuko::is_date ( const char * ptr,
size_t len )
inline
Parameters
[in]ptrPointer to a C-style string.
lenLength of the string referenced by ptr, excluding the null terminator.
Returns
Whether ptr refers to a XXXX-YY-ZZ date, for approximately valid combinations of YY and ZZ (see is_date_prefix() for details).

◆ is_date_prefix()

bool ritsuko::is_date_prefix ( const char * ptr)
inline

Does a string start with a XXXX-YY-ZZ date, for approximately valid combinations of YY and ZZ? (This is only approximate as we do not check the exact correctness of the number of days for each month.)

Parameters
[in]ptrPointer to a C-style string containing at least 10 characters.
Returns
Whether or not the string starts with a date.

◆ is_rfc3339()

bool ritsuko::is_rfc3339 ( const char * ptr,
size_t len )
inline

Does a string follow the RFC3339 format? This uses is_date_prefix() and is_rfc3339_suffix() to check the date and the rest of the timestamp, respectively.

Parameters
[in]ptrPointer to a C-style string.
lenLength of the string in ptr.
Returns
Whether or not the string is RFC3339-compliant.

◆ is_rfc3339_suffix()

bool ritsuko::is_rfc3339_suffix ( const char * ptr,
size_t len )
inline

Does a string finish with an RFC3339-compliant timestamp, i.e., does the substring starting at T after the date follow the RFC3339 specification? Note that the timestamp validity checks are only approximate as the correctness of leap seconds are not currently considered. It is expected that the start of the string up to the T was already validated with is_date_prefix().

Parameters
[in]ptrPointer to a character array containing at least 10 characters. This should start from the 10th position in the original string, i.e., T in the timestamp.
lenLength of the string in ptr.
Returns
Whether or not the string finishes with an RFC3339-compliant timestamp.

◆ parse_version_string()

Version ritsuko::parse_version_string ( const char * version_string,
size_t size,
bool skip_patch = false )
inline
Parameters
[in]version_stringPointer to a version string.
sizeLength of the version_string.
skip_patchWhether to skip the patch number.
Returns
A Version object containing the version number. If skip_patch = true, the patch number is always zero.