1/*************************************************************************/
2/* */
3/* Language Technologies Institute */
4/* Carnegie Mellon University */
5/* Copyright (c) 1999 */
6/* All Rights Reserved. */
7/* */
8/* Permission is hereby granted, free of charge, to use and distribute */
9/* this software and its documentation without restriction, including */
10/* without limitation the rights to use, copy, modify, merge, publish, */
11/* distribute, sublicense, and/or sell copies of this work, and to */
12/* permit persons to whom this work is furnished to do so, subject to */
13/* the following conditions: */
14/* 1. The code must retain the above copyright notice, this list of */
15/* conditions and the following disclaimer. */
16/* 2. Any modifications must be clearly marked as such. */
17/* 3. Original authors' names are not deleted. */
18/* 4. The authors' names are not used to endorse or promote products */
19/* derived from this software without specific prior written */
20/* permission. */
21/* */
22/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
23/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
26/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30/* THIS SOFTWARE. */
31/* */
32/*************************************************************************/
33/* Author: Alan W Black (awb@cs.cmu.edu) */
34/* Date: December 1999 */
35/*************************************************************************/
36/* */
37/* feature-values lists */
38/* */
39/*************************************************************************/
40#ifndef _CST_FEATURES_H__
41#define _CST_FEATURES_H__
42
43#include "cst_alloc.h"
44#include "cst_val.h"
45#include "cst_string.h"
46
47typedef struct cst_featvalpair_struct {
48 const char *name;
49 cst_val *val;
50 struct cst_featvalpair_struct *next;
51} cst_featvalpair;
52
53typedef struct cst_features_struct {
54 struct cst_featvalpair_struct *head;
55 cst_alloc_context ctx;
56 cst_val *owned_strings; /* fnames that are owned by this struct */
57
58 /* Link to other cst_features that we search too */
59 const struct cst_features_struct *linked;
60} cst_features;
61
62/* Constructor functions */
63cst_features *new_features(void);
64cst_features *new_features_local(cst_alloc_context ctx);
65void delete_features(cst_features *f);
66
67/* Accessor functions */
68int feat_int(const cst_features *f, const char *name);
69float feat_float(const cst_features *f, const char *name);
70const char *feat_string(const cst_features *f, const char *name);
71const cst_val *feat_val(const cst_features *f, const char *name);
72
73int get_param_int(const cst_features *f, const char *name,int def);
74float get_param_float(const cst_features *f, const char *name, float def);
75const char *get_param_string(const cst_features *f, const char *name, const char *def);
76const cst_val *get_param_val(const cst_features *f, const char *name, cst_val *def);
77
78/* Setting functions */
79void feat_set_int(cst_features *f, const char *name, int v);
80void feat_set_float(cst_features *f, const char *name, float v);
81void feat_set_string(cst_features *f, const char *name, const char *v);
82void feat_set(cst_features *f, const char *name,const cst_val *v);
83
84int feat_remove(cst_features *f,const char *name);
85int feat_present(const cst_features *f,const char *name);
86int feat_length(const cst_features *f);
87
88/* Feature names are expected to be literals -- its *much* faster to do */
89/* look ups and less alloc/frees are necesssary. Almosts always this is */
90/* fine, but when you are making up new fnames, you can get a copy of the */
91/* string that will be deleted when the cst_features is deleted */
92const char *feat_own_string(cst_features *f,const char *name);
93
94CST_VAL_USER_TYPE_DCLS(features,cst_features)
95
96int feat_copy_into(const cst_features *from,cst_features *to);
97/* Link FROM into TO so FROM's features will be searched after TO's features */
98int feat_link_into(const cst_features *from,cst_features *to);
99/* For debugging */
100int cst_feat_print(cst_file fd,const cst_features *f);
101
102#endif
103

source code of include/flite/cst_features.h