added helper functions
[yaz-moved-to-github.git] / include / yaz / facet.h
1
2 #ifndef YAZ_FACET_H
3 #define YAZ_FACET_H
4
5 #include <yaz/yconfig.h>
6 #include <yaz/odr.h>
7 #include <yaz/z-core.h>
8 #include <yaz/z-facet-1.h>
9 #include <yaz/log.h>
10
11 YAZ_BEGIN_CDECL
12
13
14 /*
15  * Helper function for extracting facet values from the ASN structures.
16  *
17  */
18
19 /* A helper structure to extract all the attribute stuff
20    from one Z_AttributesList. The pointers will all be to
21    the Z-structures, or to constants, so there is no need to
22    worry about freeing them */
23 struct attrvalues {
24     int  errcode;   /* set in case of errors */
25     char *errstring; /* opt */
26     const char *useattr; /* @attr 1, from a string attr */
27                    /* or number converted to a string */
28                    /* defaults to 'any' */
29     char useattrbuff[30]; /* for converting numbers to strings */
30     char *relation; /* @attr 2, defaults to '=' */
31     int limit; /* for facet attributes */
32 };
33
34
35 /* Use attribute, @attr1, can be numeric or string */
36 YAZ_EXPORT
37 void useattr ( Z_AttributeElement *ae, struct attrvalues *av );
38
39 YAZ_EXPORT
40 void relationattr ( Z_AttributeElement *ae, struct attrvalues *av );
41
42 YAZ_EXPORT
43 void limitattr ( Z_AttributeElement *ae, struct attrvalues *av );
44
45 YAZ_EXPORT
46 void limitattr ( Z_AttributeElement *ae, struct attrvalues *av );
47
48 YAZ_EXPORT
49 void facetattrs( Z_AttributeList *attributes, struct attrvalues *av );
50
51 YAZ_EXPORT
52 Z_FacetList *extract_facet_request(ODR odr, Z_OtherInformation *search_input);
53
54 YAZ_EXPORT
55 Z_Term *term_create(ODR odr, const char *cstr);
56
57 YAZ_EXPORT
58 Z_FacetTerm* facet_term_create(ODR odr, Z_Term *term, int freq);
59
60 YAZ_EXPORT
61 Z_FacetField* facet_field_create(ODR odr, Z_AttributeList *attributes, int num_terms);
62
63 YAZ_EXPORT
64 void facet_field_term_set(ODR odr, Z_FacetField *field, Z_FacetTerm *facetTerm, int index);
65
66 YAZ_EXPORT
67 Z_FacetList* facet_list_create(ODR odr, int num_facets);
68
69 YAZ_EXPORT
70 void facet_list_field_set(ODR odr, Z_FacetList *list, Z_FacetField *field, int index);
71
72 #endif