MongoDBCDriver
0.7.1
|
00001 00006 /* Copyright 2009-2012 10gen Inc. 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); 00009 * you may not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 */ 00020 00021 #ifndef BCON_H_ 00022 #define BCON_H_ 00023 00024 #include "bson.h" 00025 00026 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00027 00028 MONGO_EXTERN_C_START 00029 00030 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 00031 00032 typedef union bcon { 00033 char *s; /* must be first to be default */ 00034 char *Rs; 00035 char **Ps; 00036 double f; 00037 double *Rf; 00038 double **Pf; 00039 union bcon *D; 00040 union bcon *RD; 00041 union bcon **PD; 00042 union bcon *A; 00043 union bcon *RA; 00044 union bcon **PA; 00045 char *o; 00046 char *Ro; 00047 char **Po; 00048 bson_bool_t b; 00050 bson_bool_t *Rb; 00051 bson_bool_t **Pb; 00052 time_t t; 00053 time_t *Rt; 00054 time_t **Pt; 00055 char *v; 00056 char *x; 00057 char *Rx; 00058 char **Px; 00059 int i; 00060 int *Ri; 00061 int **Pi; 00062 long l; 00063 long *Rl; 00064 long **Pl; 00065 void **Pv; /* generic pointer internal */ 00066 /* "{" "}" */ /* 03 e_name document Embedded document */ 00067 /* "[" "]" */ /* 04 e_name document Array */ 00068 /* 05 e_name binary Binary data */ 00069 /* 06 e_name undefined - deprecated */ 00070 /* 0B e_name cstring cstring Regular expression */ 00071 /* 0C e_name string (byte*12) DBPointer - Deprecated */ 00072 /* 0D e_name string JavaScript code */ 00073 /* 0F e_name code_w_s JavaScript code w/ scope */ 00074 /* 11 e_name int64 Timestamp */ 00075 /* FF e_name Min key */ 00076 /* 7F e_name Max key */ 00077 } bcon; 00078 00080 #define BEND "." 00081 00083 #define BTF ":_f:" 00084 00085 #define BTS ":_s:" 00086 00087 #define BTD ":_D:" 00088 00089 #define BTA ":_A:" 00090 00091 #define BTO ":_o:" 00092 00093 #define BTB ":_b:" 00094 00095 #define BTT ":_t:" 00096 00097 #define BTN ":_v:" 00098 00099 #define BTX ":_x:" 00100 00101 #define BTI ":_i:" 00102 00103 #define BTL ":_l:" 00104 00106 #define BTRF ":Rf:" 00107 00108 #define BTRS ":Rs:" 00109 00110 #define BTRD ":RD:" 00111 00112 #define BTRA ":RA:" 00113 00114 #define BTRO ":Ro:" 00115 00116 #define BTRB ":Rb:" 00117 00118 #define BTRT ":Rt:" 00119 00120 #define BTRX ":Rx:" 00121 00122 #define BTRI ":Ri:" 00123 00124 #define BTRL ":Rl:" 00125 00127 #define BTPF ":Pf:" 00128 00129 #define BTPS ":Ps:" 00130 00131 #define BTPD ":PD:" 00132 00133 #define BTPA ":PA:" 00134 00135 #define BTPO ":Po:" 00136 00137 #define BTPB ":Pb:" 00138 00139 #define BTPT ":Pt:" 00140 00141 #define BTPX ":Px:" 00142 00143 #define BTPI ":Pi:" 00144 00145 #define BTPL ":Pl:" 00146 00148 #define BF(v) BTF, { .f = (v) } 00149 00150 #define BS(v) BTS, { .s = (v) } 00151 00152 #define BD(v) BTD, { .D = (v) } 00153 00154 #define BA(v) BTA, { .A = (v) } 00155 00156 #define BO(v) BTO, { .o = (v) } 00157 00158 #define BB(v) BTB, { .b = (v) } 00159 00160 #define BT(v) BTT, { .t = (v) } 00161 00162 #define BNULL BTN, { .v = ("") } 00163 00164 #define BX(v) BTX, { .x = (v) } 00165 00166 #define BI(v) BTI, { .i = (v) } 00167 00168 #define BL(v) BTL, { .l = (v) } 00169 00171 #define BRF(v) BTRF, { .Rf = (v) } 00172 00173 #define BRS(v) BTRS, { .Rs = (v) } 00174 00175 #define BRD(v) BTRD, { .RD = (v) } 00176 00177 #define BRA(v) BTRA, { .RA = (v) } 00178 00179 #define BRO(v) BTRO, { .Ro = (v) } 00180 00181 #define BRB(v) BTRB, { .Rb = (v) } 00182 00183 #define BRT(v) BTRT, { .Rt = (v) } 00184 00185 #define BRX(v) BTRX, { .Rx = (v) } 00186 00187 #define BRI(v) BTRI, { .Ri = (v) } 00188 00189 #define BRL(v) BTRL, { .Rl = (v) } 00190 00192 #define BPF(v) BTPF, { .Pf = (v) } 00193 00194 #define BPS(v) BTPS, { .Ps = ((char**)v) } 00195 00196 #define BPD(v) BTPD, { .PD = ((union bcon **)v) } 00197 00198 #define BPA(v) BTPA, { .PA = ((union bcon **)v) } 00199 00200 #define BPO(v) BTPO, { .Po = ((char**)v) } 00201 00202 #define BPB(v) BTPB, { .Pb = (v) } 00203 00204 #define BPT(v) BTPT, { .Pt = (v) } 00205 00206 #define BPX(v) BTPX, { .Px = ((char**)v) } 00207 00208 #define BPI(v) BTPI, { .Pi = (v) } 00209 00210 #define BPL(v) BTPL, { .Pl = (v) } 00211 00212 /* 00213 * References on codes used for types 00214 * http://en.wikipedia.org/wiki/Name_mangling 00215 * http://www.agner.org/optimize/calling_conventions.pdf (page 25) 00216 */ 00217 00218 typedef enum bcon_error_t { 00219 BCON_OK = 0, 00220 BCON_ERROR, 00221 BCON_DOCUMENT_INCOMPLETE, 00222 BCON_BSON_ERROR 00223 } bcon_error_t; 00224 00225 extern char *bcon_errstr[]; 00233 MONGO_EXPORT bcon_error_t bson_append_bcon(bson *b, const bcon *bc); 00234 00241 MONGO_EXPORT bcon_error_t bson_from_bcon( bson *b, const bcon *bc ); 00242 00248 MONGO_EXPORT void bcon_print( const bcon *bc ); 00249 00250 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00251 00252 MONGO_EXTERN_C_END 00253 00254 typedef enum bcon_token_t { 00255 Token_Default, Token_End, Token_Typespec, 00256 Token_OpenBrace, Token_CloseBrace, Token_OpenBracket, Token_CloseBracket, 00257 Token_EOD 00258 } bcon_token_t; 00259 00260 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 00261 00262 #endif