UniMRCP
1.3.0
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
libs
apr-toolkit
include
apt_pair.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008-2014 Arsen Chaloyan
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
* $Id: apt_pair.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17
*/
18
19
#ifndef APT_PAIR_H
20
#define APT_PAIR_H
21
22
/**
23
* @file apt_pair.h
24
* @brief Generic Name-Value Pair
25
*/
26
27
#include <apr_tables.h>
28
#include "
apt_string.h
"
29
30
APT_BEGIN_EXTERN_C
31
32
/** Name-value declaration */
33
typedef
struct
apt_pair_t
apt_pair_t
;
34
35
/** Generic name-value pair definition ("name:value") */
36
struct
apt_pair_t
{
37
/** The name */
38
apt_str_t
name
;
39
/** The value */
40
apt_str_t
value
;
41
};
42
43
/** Dynamic array of name-value pairs */
44
typedef
apr_array_header_t
apt_pair_arr_t
;
45
46
/** Initialize name-value pair */
47
static
APR_INLINE
void
apt_pair_init(
apt_pair_t
*pair)
48
{
49
apt_string_reset(&pair->
name
);
50
apt_string_reset(&pair->
value
);
51
}
52
53
/** Copy name-value pair */
54
static
APR_INLINE
void
apt_pair_copy(
apt_pair_t
*pair,
const
apt_pair_t
*src_pair, apr_pool_t *pool)
55
{
56
apt_string_copy(&pair->
name
,&src_pair->
name
,pool);
57
apt_string_copy(&pair->
value
,&src_pair->
value
,pool);
58
}
59
60
/** Create array of name-value pairs */
61
APT_DECLARE
(
apt_pair_arr_t
*)
apt_pair_array_create
(apr_size_t initial_size, apr_pool_t *pool);
62
/** Copy array of name-value pairs */
63
APT_DECLARE
(
apt_pair_arr_t
*)
apt_pair_array_copy
(const
apt_pair_arr_t
*src, apr_pool_t *pool);
64
/** Append name-value pair */
65
APT_DECLARE
(
apt_bool_t
)
apt_pair_array_append
(
apt_pair_arr_t
*arr, const
apt_str_t
*name, const
apt_str_t
*value, apr_pool_t *pool);
66
/** Find name-value pair by name */
67
APT_DECLARE
(const
apt_pair_t
*)
apt_pair_array_find
(const
apt_pair_arr_t
*arr, const
apt_str_t
*name);
68
/** Get size of pair array */
69
APT_DECLARE
(
int
)
apt_pair_array_size_get
(const
apt_pair_arr_t
*arr);
70
/** Get name-value pair by id */
71
APT_DECLARE
(const
apt_pair_t
*)
apt_pair_array_get
(const
apt_pair_arr_t
*arr,
int
id
);
72
73
APT_END_EXTERN_C
74
75
#endif
/* APT_PAIR_H */
Generated on Mon Feb 2 2015 19:41:38 for UniMRCP by
1.8.3.1