Data Structures | |
struct | rxv_spin_data |
Defines | |
#define | rxv_spin_single_trimboth(s) rxv_spin_single_trim((s),(RXV_SPIN_TRIM_LEFT|RXV_SPIN_TRIM_RIGHT)) |
#define | rxv_spin_single_trimleft(s) rxv_spin_single_trim((s),(RXV_SPIN_TRIM_LEFT)) |
#define | rxv_spin_single_trimright(s) rxv_spin_single_trim((s),(RXV_SPIN_TRIM_RIGHT)) |
#define | rxv_spin_column_del(rows, key) rxv_spin_column_set((rows),(key),NULL) |
#define | rxv_spin_str_trimboth(s) rxv_spin_str_trim((s),(RXV_SPIN_TRIM_LEFT|RXV_SPIN_TRIM_RIGHT)) |
#define | rxv_spin_str_trimleft(s) rxv_spin_str_trim((s),(RXV_SPIN_TRIM_LEFT)) |
#define | rxv_spin_str_trimright(s) rxv_spin_str_trim((s),(RXV_SPIN_TRIM_RIGHT)) |
Typedefs | |
typedef rxv_spin_data | rxv_spin_data_t |
Enumerations | |
enum | rxv_spin_data_e { RXV_SPIN_DATA_SGL = 1, RXV_SPIN_DATA_RWS, RXV_SPIN_DATA_MTA } |
enum | rxv_spin_trim_e { RXV_SPIN_TRIM_LEFT = 1, RXV_SPIN_TRIM_RIGHT } |
Functions | |
rxv_spin_data_t * | rxv_spin_single (apr_pool_t *pool, const char *str) |
char * | rxv_spin_single_get (rxv_spin_data_t *single) |
rxv_spin_data_t * | rxv_spin_single_set (rxv_spin_data_t *single, const char *str) |
rxv_spin_data_t * | rxv_spin_single_mem (apr_pool_t *pool, const char *str, apr_size_t size) |
rxv_spin_data_t * | rxv_spin_single_memset (rxv_spin_data_t *single, const char *str, apr_size_t size) |
rxv_spin_data_t * | rxv_spin_single_tolower (rxv_spin_data_t *single) |
rxv_spin_data_t * | rxv_spin_single_toupper (rxv_spin_data_t *single) |
rxv_spin_data_t * | rxv_spin_single_trim (rxv_spin_data_t *single, rxv_spin_trim_e what) |
rxv_spin_data_t * | rxv_spin_meta (apr_pool_t *pool,...) |
rxv_spin_data_t * | rxv_spin_meta_vstr (apr_pool_t *pool,...) |
rxv_spin_data_t * | rxv_spin_meta_parse (apr_pool_t *pool, char *str, const char *sep) |
rxv_spin_data_t * | rxv_spin_meta_brigade (apr_pool_t *pool, apr_bucket_brigade *bb) |
rxv_spin_data_t * | rxv_spin_meta_empty (apr_pool_t *pool, apr_size_t size) |
apr_hash_t * | rxv_spin_meta_hash (apr_pool_t *pool, rxv_spin_data_t *data) |
rxv_spin_data_t * | rxv_spin_meta_mark (rxv_spin_data_t *data, apr_size_t element) |
rxv_spin_data_t * | rxv_spin_meta_markeach (rxv_spin_data_t *data, apr_size_t off, apr_size_t step) |
rxv_spin_data_t * | rxv_spin_meta_select (rxv_spin_data_t *data, rxv_spin_data_t *select, apr_hash_t *hash) |
rxv_spin_data_t * | rxv_spin_rows (apr_pool_t *pool,...) |
apr_hash_t * | rxv_spin_rows_hash (apr_pool_t *pool, rxv_spin_data_t *rows, const char *column) |
rxv_spin_data_t * | rxv_spin_rows_mark (rxv_spin_data_t *rows, const char *column, apr_size_t element) |
rxv_spin_data_t * | rxv_spin_rows_markeach (rxv_spin_data_t *rows, const char *column, apr_size_t off, apr_size_t step) |
rxv_spin_data_t * | rxv_spin_rows_select (rxv_spin_data_t *rows, rxv_spin_data_t *select, const char *column, const char *marker, apr_hash_t *hash) |
rxv_spin_data_t * | rxv_spin_column_get (apr_pool_t *pool, rxv_spin_data_t *rows, const char *key) |
rxv_spin_data_t * | rxv_spin_column_set (rxv_spin_data_t *rows, const char *key, rxv_spin_data_t *column) |
rxv_spin_data_t * | rxv_spin_resize (apr_pool_t *pool, rxv_spin_data_t *data, apr_size_t size) |
rxv_spin_data_t * | rxv_spin_copy (apr_pool_t *pool, rxv_spin_data_t *data) |
char * | rxv_spin_str_tolower (const char *str) |
char * | rxv_spin_str_toupper (const char *str) |
char * | rxv_spin_str_trim (char *str, rxv_spin_trim_e what) |
#define rxv_spin_single_trimboth | ( | s | ) | rxv_spin_single_trim((s),(RXV_SPIN_TRIM_LEFT|RXV_SPIN_TRIM_RIGHT)) |
trim single on both sides
#define rxv_spin_single_trimleft | ( | s | ) | rxv_spin_single_trim((s),(RXV_SPIN_TRIM_LEFT)) |
trim single on the left side
#define rxv_spin_single_trimright | ( | s | ) | rxv_spin_single_trim((s),(RXV_SPIN_TRIM_RIGHT)) |
trim single on the right side
#define rxv_spin_column_del | ( | rows, | |||
key | ) | rxv_spin_column_set((rows),(key),NULL) |
delete a column from rows
#define rxv_spin_str_trimboth | ( | s | ) | rxv_spin_str_trim((s),(RXV_SPIN_TRIM_LEFT|RXV_SPIN_TRIM_RIGHT)) |
trim string on both sides
#define rxv_spin_str_trimleft | ( | s | ) | rxv_spin_str_trim((s),(RXV_SPIN_TRIM_LEFT)) |
trim string on the left side
#define rxv_spin_str_trimright | ( | s | ) | rxv_spin_str_trim((s),(RXV_SPIN_TRIM_RIGHT)) |
trim string on the right side
typedef struct rxv_spin_data rxv_spin_data_t |
data type
enum rxv_spin_data_e |
enum rxv_spin_trim_e |
rxv_spin_data_t* rxv_spin_single | ( | apr_pool_t * | pool, | |
const char * | str | |||
) |
Create single data from from a nul terminated string. String is not copied - use apr_pstrdup() for that.
pool | Pool for allocation of data structure | |
str | String to create data from |
rxv_spin_single(pool,"some string");
char* rxv_spin_single_get | ( | rxv_spin_data_t * | single | ) |
Get a nul terminated string from the single data. String is not copied, use apr_pstrdup() for that.
single | Single data |
rxv_spin_single_get(data);
rxv_spin_data_t* rxv_spin_single_set | ( | rxv_spin_data_t * | single, | |
const char * | str | |||
) |
Replace data (string) in an already existing single. String is not copied - use apr_pstrdup() for that.
single | Already exisiting single | |
str | String to replace within single |
rxv_spin_single_set(single,"some new string");
rxv_spin_data_t* rxv_spin_single_mem | ( | apr_pool_t * | pool, | |
const char * | str, | |||
apr_size_t | size | |||
) |
Create single data from from a counted string. Although the string is counted, it has to end with a nul character. This function will check for it and if it isn't there, it'll refuse to create the single. Keep in mind that the memory allocated for the counted string will be size + 1, meaning, if it isn't, the check for that nul character at the end may cause a segfault. String is not copied - use apr_pstrmemdup() for that.
pool | Pool for allocation of data structure | |
str | String to create data from | |
size | Size of the string, not counting the ending nul character |
rxv_spin_single_mem(pool,"1234567890",10);
rxv_spin_data_t* rxv_spin_single_memset | ( | rxv_spin_data_t * | single, | |
const char * | str, | |||
apr_size_t | size | |||
) |
Replace data (counted string) in an already existing single. Although the string is counted, it has to end with a nul character. This function will check for it and if it isn't there, it'll refuse to create the single. Keep in mind that the memory allocated for the counted string will be size + 1, meaning, if it isn't, the check for that nul character at the end may cause a segfault. String is not copied - use apr_pstrmemdup() for that.
single | Already exisiting single | |
str | String to replace within single | |
size | Size of the string, not counting the ending nul character |
rxv_spin_single_memset(single,"1234567890",10);
rxv_spin_data_t* rxv_spin_single_tolower | ( | rxv_spin_data_t * | single | ) |
Convert a single to lowercase. Single pushed into the function is modified, no copy is made.
single | Single data |
rxv_spin_single_tolower(single);
rxv_spin_data_t* rxv_spin_single_toupper | ( | rxv_spin_data_t * | single | ) |
Convert a single to uppercase. Single pushed into the function is modified, no copy is made.
single | Single data |
rxv_spin_single_toupper(single);
rxv_spin_data_t* rxv_spin_single_trim | ( | rxv_spin_data_t * | single, | |
rxv_spin_trim_e | what | |||
) |
Trim whitespace from a single. No copy is made.
single | Single data | |
what | Trim left: RXV_SPIN_TRIM_LEFT, trim right: RXV_SPIN_TRIM_RIGHT |
rxv_spin_data_t* rxv_spin_meta | ( | apr_pool_t * | pool, | |
... | ||||
) |
Create metadata from data. Meta data is an array of rxv_spin_data_t. It is not used to place data into the context, but simply to facilitate the API. Data is not copied.
pool | Pool for allocation of data structure | |
... | List of rxv_spin_data_t*, ending with NULL |
rxv_spin_meta(pool, rxv_spin_rows(pool,"x",x,"y",y,"z",z,NULL), rxv_spin_rows(pool,"u",u,"v",v,"w",w,NULL), NULL);
rxv_spin_data_t* rxv_spin_meta_vstr | ( | apr_pool_t * | pool, | |
... | ||||
) |
Create metadata from from nul terminated strings. Meta data is an array of rxv_spin_data_t. It is not used to place data into the context, but simply to facilitate the API. Strings are not copied - use apr_pstrdup() for that.
pool | Pool for allocation of data structure | |
... | List of char*, ending with NULL |
rxv_spin_meta_vstr(pool,"first string","second string",NULL);
rxv_spin_data_t* rxv_spin_meta_parse | ( | apr_pool_t * | pool, | |
char * | str, | |||
const char * | sep | |||
) |
Create metadata by parsing a string. Meta data is an array of rxv_spin_data_t. It is not used to place data into the context, but simply to facilitate the API. String to parse is NOT copied into pool storage before parsing, therefore, if you want to parse constant strings, you MUST copy them using apr_pstrdup(). This function actually chops up the string that is passed into it, so if the string is supposed to be used somewhere else, you may get a nasty surprise after calling this function. It is safer to make a copy.
pool | Pool for allocation of data structure | |
str | String to parse | |
sep | Separators to use when parsing |
rxv_spin_meta_parse(pool, apr_pstrdup(pool,"first str,second str/third str"), ",/");
rxv_spin_data_t* rxv_spin_meta_brigade | ( | apr_pool_t * | pool, | |
apr_bucket_brigade * | bb | |||
) |
Create metadata by reading a bucket brigade. Meta data is an array of rxv_spin_data_t. It is not used to place data into the context, but simply to facilitate the API. All read data is copied into the storage allocated from the pool.
pool | Pool for allocation of data structure | |
bb | Bucket brigade to read |
rxv_spin_meta_brigade(pool,bb);
rxv_spin_data_t* rxv_spin_meta_empty | ( | apr_pool_t * | pool, | |
apr_size_t | size | |||
) |
Create an empty column of data. The size of the column is usually picked up from an existing rows data type. The returned value is metadata and its size is embedded in it.
pool | Pool for allocation of data structures | |
size | Size (number of elements) of the column to create |
rxv_spin_meta_empty(pool,rows->size);
apr_hash_t* rxv_spin_meta_hash | ( | apr_pool_t * | pool, | |
rxv_spin_data_t * | data | |||
) |
Create a hash table of metadata. Keys will be strings from singles, values will be pointers to the actual singles. Data other than singles will not be hashed.
pool | Pool for all memory allocation | |
data | Meta data to hash |
rxv_spin_meta_hash(pool,data);
rxv_spin_data_t* rxv_spin_meta_mark | ( | rxv_spin_data_t * | data, | |
apr_size_t | element | |||
) |
Mark an element in the metadata (associate an empty string to it). This is useful for creating markers for the presentation layer. The data passed into this function is metadata, meaning, the size is embedded in it.
data | Data to mark | |
element | The index of the element to mark |
rxv_spin_meta_mark(data,rows->size-1);
rxv_spin_data_t* rxv_spin_meta_markeach | ( | rxv_spin_data_t * | data, | |
apr_size_t | off, | |||
apr_size_t | step | |||
) |
Mark each n-th element in the metadata (associate an empty string to it). This is useful for creating markers for the presentation layer. The data passed into this function metadata, meaning, the size is embedded in it.
data | Data to mark | |
off | Offset to start from | |
step | Each n-th element to mark |
rxv_spin_meta_markeach(data,1,2);
rxv_spin_data_t* rxv_spin_meta_select | ( | rxv_spin_data_t * | data, | |
rxv_spin_data_t * | select, | |||
apr_hash_t * | hash | |||
) |
Select (mark) data that matches given data set. Selection data set is either single or metadata. The select operation can use an optional hash of the data that is being matched. Otherwise, the search is linear (which is OK for small data sets).
data | Data to select | |
select | Single or metadata to use for selection | |
hash | Optional hash of the data being matched or NULL |
rxv_spin_meta_select(data,rxv_spin_str_parse(pool,"Australia,Japan",","), rxv_spin_meta_hash(pool,data));
rxv_spin_data_t* rxv_spin_rows | ( | apr_pool_t * | pool, | |
... | ||||
) |
Create rows of data from metadata. The list supplied contains alternating column names, which are strings, and the actual data for the column, in form of metadata. If metadata contains different array lengths, the smallest size will be used. Data is not copied.
pool | Pool for allocation of data structure | |
... | List of char* and rxv_spin_data_t*, ending with NULL |
rxv_spin_rows(pool,"def",def,"ghi",ghi,"xyz",xyz,NULL);
apr_hash_t* rxv_spin_rows_hash | ( | apr_pool_t * | pool, | |
rxv_spin_data_t * | rows, | |||
const char * | column | |||
) |
Create a hash table of a column of rows. Keys will be strings from singles, values will be pointers to the actual singles. Data other than singles will not be hashed.
pool | Pool for all memory allocation | |
rows | Rows to hash | |
column | Column to hash |
rxv_spin_rows_hash(pool,rows,"secondcolumn");
rxv_spin_data_t* rxv_spin_rows_mark | ( | rxv_spin_data_t * | rows, | |
const char * | column, | |||
apr_size_t | element | |||
) |
Mark an element in the column of rows (associate an empty string to it). This is useful for creating markers for the presentation layer.
rows | Rows to mark | |
column | Name of the column to mark | |
element | The index of the element to mark |
rxv_spin_rows_mark(rows,"lastrow",rows->size-1);
rxv_spin_data_t* rxv_spin_rows_markeach | ( | rxv_spin_data_t * | rows, | |
const char * | column, | |||
apr_size_t | off, | |||
apr_size_t | step | |||
) |
Mark each n-th element in the column of rows (associate an empty string to it). This is useful for creating markers for the presentation layer.
rows | Rows to mark | |
column | Name of the column to mark | |
off | Offset to start from | |
step | Each n-th element to mark |
rxv_spin_rows_markeach(rows,"evenrow",0,2);
rxv_spin_data_t* rxv_spin_rows_select | ( | rxv_spin_data_t * | rows, | |
rxv_spin_data_t * | select, | |||
const char * | column, | |||
const char * | marker, | |||
apr_hash_t * | hash | |||
) |
Select (mark) rows of data that match given data set. Selection data set is either single or metadata. The select operation can use an optional hash of the column that is being matched. Otherwise, the search is linear (which is OK for small data sets).
rows | Rows of data to select | |
select | Single or metadata to use for selection | |
column | Column used to match the data from select parameter | |
marker | Column used to place markers for selected data | |
hash | Optional hash of the column being matched or NULL |
rxv_spin_rows_select(rows,rxv_spin_str_parse(pool,"Australia,Japan",","), "country","selected", rxv_spin_rows_hash(pool,rows,"country"));
rxv_spin_data_t* rxv_spin_column_get | ( | apr_pool_t * | pool, | |
rxv_spin_data_t * | rows, | |||
const char * | key | |||
) |
Get a column from rows data type. The column is not copied, rather a pointer to the first element in the array is returned inside a metadata type. Being metadata, this column will have its size embedded in it.
pool | Pool for allocation of data structure | |
rows | Rows data type | |
key | Name of the column to get |
column=rxv_spin_column_get(rows,"firstfield"); for(i=0;i<rows->size;i++) rxv_spin_single_toupper(column+i);
rxv_spin_data_t* rxv_spin_column_set | ( | rxv_spin_data_t * | rows, | |
const char * | key, | |||
rxv_spin_data_t * | column | |||
) |
Set a column in rows data type. The column passed into this function is metadata. The size of the column has to be equal of greater than the number of rows.
rows | Rows data type | |
key | Name of the column to set | |
column | Column to set |
rxv_spin_column_set(rows,"newcolumn",rxv_spin_column(rows->size));
rxv_spin_data_t* rxv_spin_resize | ( | apr_pool_t * | pool, | |
rxv_spin_data_t * | data, | |||
apr_size_t | size | |||
) |
Resize rows or metadata.
pool | Pool for all memory allocation | |
data | Data, rows or metadata type only | |
size | New size |
rxv_spin_resize(pool,data,100);
rxv_spin_data_t* rxv_spin_copy | ( | apr_pool_t * | pool, | |
rxv_spin_data_t * | data | |||
) |
Make a copy of data. The result is a full, deep copy (i.e. there is not a single byte in common with the original).
pool | Pool for all memory allocation | |
data | Data, any type |
rxv_spin_copy(pool,data);
char* rxv_spin_str_tolower | ( | const char * | str | ) |
Convert a string to lowercase. String pushed into the function is modified, no copy is made.
str | String to convert, nul terminated |
rxv_spin_str_tolower(single);
char* rxv_spin_str_toupper | ( | const char * | str | ) |
Convert a string to uppercase. String pushed into the function is modified, no copy is made.
str | String to convert, nul terminated |
rxv_spin_str_toupper(single);
char* rxv_spin_str_trim | ( | char * | str, | |
rxv_spin_trim_e | what | |||
) |
Trim whitespace from a string. No copy is made. You MUST copy the string into pool storage using apr_pstrdup() if you're trimming constant strings.
str | String | |
what | Trim left: RXV_SPIN_TRIM_LEFT, trim right: RXV_SPIN_TRIM_RIGHT |
rxv_spin_str_trim(apr_strdup(pool," string with whitespace ", RXV_SPIN_TRIM_LEFT|RXV_SPIN_TRIM_RIGHT);