1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2010 Index Data.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Index Data nor the names of its contributors
13 * may be used to endorse or promote products derived from this
14 * software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * \brief Header for the facet utilities
36 #include <yaz/yconfig.h>
38 #include <yaz/z-core.h>
39 #include <yaz/z-facet-1.h>
46 * Helper function for extracting facet values from the ASN structures.
50 /* A helper structure to extract all the attribute stuff
51 from one Z_AttributesList. The pointers will all be to
52 the Z-structures, or to constants, so there is no need to
53 worry about freeing them */
55 int errcode; /* set in case of errors */
56 char *errstring; /* opt */
57 const char *useattr; /* @attr 1, from a string attr */
58 /* or number converted to a string */
59 /* defaults to 'any' */
60 char useattrbuff[30]; /* for converting numbers to strings */
61 char *relation; /* @attr 2, defaults to '=' */
62 int limit; /* for facet attributes */
66 void facet_struct_init(struct attrvalues *attr_values);
68 /* Use attribute, @attr1, can be numeric or string */
70 void useattr ( Z_AttributeElement *ae, struct attrvalues *av );
73 void relationattr ( Z_AttributeElement *ae, struct attrvalues *av );
76 void limitattr ( Z_AttributeElement *ae, struct attrvalues *av );
79 void limitattr ( Z_AttributeElement *ae, struct attrvalues *av );
82 void facetattrs( Z_AttributeList *attributes, struct attrvalues *av );
85 Z_FacetList *extract_facet_request(ODR odr, Z_OtherInformation *search_input);
88 Z_Term *term_create(ODR odr, const char *cstr);
91 Z_FacetTerm* facet_term_create(ODR odr, Z_Term *term, int freq);
94 Z_FacetField* facet_field_create(ODR odr, Z_AttributeList *attributes, int num_terms);
97 void facet_field_term_set(ODR odr, Z_FacetField *field, Z_FacetTerm *facetTerm, int index);
100 Z_FacetList* facet_list_create(ODR odr, int num_facets);
103 void facet_list_field_set(ODR odr, Z_FacetList *list, Z_FacetField *field, int index);
109 * c-file-style: "Stroustrup"
110 * indent-tabs-mode: nil
112 * vim: shiftwidth=4 tabstop=8 expandtab