00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: apt_string_table.h 1474 2010-02-07 20:51:47Z achaloyan $ 00017 */ 00018 00019 #ifndef APT_STRING_TABLE_H 00020 #define APT_STRING_TABLE_H 00021 00022 /** 00023 * @file apt_string_table.h 00024 * @brief Generic String Table 00025 */ 00026 00027 #include "apt_string.h" 00028 00029 APT_BEGIN_EXTERN_C 00030 00031 00032 /** String table item declaration */ 00033 typedef struct apt_str_table_item_t apt_str_table_item_t; 00034 00035 /** String table item definition */ 00036 struct apt_str_table_item_t { 00037 /** String value associated with id */ 00038 apt_str_t value; 00039 /** Index of the unique (key) character to compare */ 00040 apr_size_t key; 00041 }; 00042 00043 00044 /** 00045 * Get the string by a given id. 00046 * @param table the table to get string from 00047 * @param size the size of the table 00048 * @param id the id to get string by 00049 * @return the string associated with the id, or NULL if the id is invalid 00050 */ 00051 APT_DECLARE(const apt_str_t*) apt_string_table_str_get(const apt_str_table_item_t table[], apr_size_t size, apr_size_t id); 00052 00053 /** 00054 * Find the id associated with a given string. 00055 * @param table the table to search for the id 00056 * @param size the size of the table 00057 * @param value the string to search for 00058 * @return the id associated with the string, or invalid id if string cannot be matched 00059 */ 00060 APT_DECLARE(apr_size_t) apt_string_table_id_find(const apt_str_table_item_t table[], apr_size_t size, const apt_str_t *value); 00061 00062 00063 APT_END_EXTERN_C 00064 00065 #endif /* APT_STRING_TABLE_H */