xref: /illumos-gate/usr/src/lib/libnisdb/db_query_c.x (revision d48be21240dfd051b689384ce2b23479d757f2d8)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	db_query_c.x
24  *
25  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 #if RPC_HDR
30 %#ifndef _DB_QUERY_H
31 %#define _DB_QUERY_H
32 
33 %
34 %/* db_query is the structure that contains the components of a query.
35 %   It contains the values for searching the indices. */
36 %
37 
38 #ifdef USINGC
39 %#include "db_item_c.h"
40 %#include "db_entry_c.h"
41 %#include "db_scheme_c.h"
42 #else
43 %#include "db_item.h"
44 %#include "db_entry.h"
45 %#include "db_scheme.h"
46 #endif /* USINGC */
47 #endif /* RPC_HDR */
48 
49 %/* A component of a query */
50 struct db_qcomp {
51   int which_index;             /* identifies which index is being used */
52   item* index_value;           /* value to be used in search */
53 };
54 
55 #if RPC_HDR || RPC_XDR
56 #ifdef USINGC
57 struct db_query {
58   db_qcomp components<>;
59 };
60 #endif /* USINGC */
61 #endif /* RPC_HDR */
62 
63 #ifndef USINGC
64 #ifdef RPC_HDR
65 %
66 %class db_query {
67 %protected:
68 %  int num_components;
69 %  db_qcomp* components;
70 % public:
71 %/* Accessor:  returns number of components */
72 %  int size() { return num_components; }
73 %
74 %/* Accessor:  returns location of start of query */
75 %   db_qcomp* queryloc() { return components; }
76 %
77 %
78 %/* Null constructor:  returns empty empty query. */
79 %  db_query() { num_components = 0; components = NULL; }
80 %
81 %/* Returns a db_query containing the index values as obtained from
82 %   'attrlist.' */
83 %  db_query( db_scheme*, int, nis_attr* );
84 %
85 %/* Returns a newly db_query containing the index values as
86 %   obtained from the given object.  The object itself,
87 %   along with information on the scheme given, will determine
88 %   which values are extracted from the object and placed into the query.
89 %   Returns an empty query if 'obj' is not a valid entry.
90 %   Note that space is allocated for the query and the index values
91 %   (i.e. do not share pointers with strings in 'obj'.)
92 %*/
93 %  db_query( db_scheme*, entry_object_p );
94 %
95 %  /* destructor (frees all components) */
96 %  ~db_query();
97 %
98 %  /* clear component structure */
99 %  void clear_components( int );
100 %
101 %/* Print all components of this query to stdout. */
102 %  void print();
103 %};
104 %typedef class db_query * db_query_p;
105 #endif /* RPC_HDR */
106 #endif /* USINGC */
107 
108 #if RPC_HDR
109 %#endif /* _DB_QUERY_H */
110 #endif /* RPC_HDR */
111