Annotation of parser3/src/classes/table.C, revision 1.62
1.20 paf 1: /** @file
1.47 paf 2: Parser: @b table parser class.
1.20 paf 3:
1.1 paf 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.20 paf 5:
1.1 paf 6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
7:
1.62 ! paf 8: $Id: table.C,v 1.61 2001/04/15 13:12:18 paf Exp $
1.1 paf 9: */
10:
1.24 paf 11: #include "pa_config_includes.h"
1.59 paf 12:
13: #include "pcre.h"
14:
1.16 paf 15: #include "pa_common.h"
1.1 paf 16: #include "pa_request.h"
17: #include "_table.h"
18: #include "pa_vtable.h"
1.6 paf 19: #include "pa_vint.h"
1.51 paf 20: #include "pa_sql_connection.h"
1.58 paf 21: #include "pa_dir.h"
1.1 paf 22:
23: // global var
24:
1.14 paf 25: VStateless_class *table_class;
1.1 paf 26:
27: // methods
1.61 paf 28: static void _set(Request& r, const String& method_name, MethodParams *params) {
1.1 paf 29: Pool& pool=r.pool();
30: // data is last parameter
1.61 paf 31: Value& vdata=params->get_junction(params->size()-1, "body must be code");
1.44 paf 32:
1.45 paf 33: Temp_lang temp_lang(r, String::UL_PASS_APPENDED);
1.61 paf 34: const String& data=r.process(vdata).as_string();
1.44 paf 35:
36: size_t pos_after=0;
37: // parse columns
38: Array *columns;
39: if(params->size()==2) {
40: columns=0;
1.21 paf 41: } else {
1.44 paf 42: columns=new(pool) Array(pool);
43:
44: Array head(pool);
45: data.split(head, &pos_after, "\n", 1, String::UL_CLEAN, 1);
46: if(head.size())
47: head.get_string(0)->split(*columns, 0, "\t", 1, String::UL_CLEAN);
48: }
49:
50: Table& table=*new(pool) Table(pool, &method_name, columns);
51: // parse cells
52: Array rows(pool);
53: data.split(rows, &pos_after, "\n", 1, String::UL_CLEAN);
54: int size=rows.quick_size();
55: for(int i=0; i<size; i++) {
56: Array& row=*new(pool) Array(pool);
57: const String& string=*rows.quick_get_string(i);
58: // remove empty lines
59: if(!string.size())
60: continue;
61:
62: string.split(row, 0, "\t", 1, String::UL_CLEAN);
63: table+=&row;
1.17 paf 64: }
1.1 paf 65:
1.44 paf 66: // replace any previous table value
67: static_cast<VTable *>(r.self)->set_table(table);
68: }
69:
1.61 paf 70: static void _load(Request& r, const String& method_name, MethodParams *params) {
1.44 paf 71: Pool& pool=r.pool();
72: // filename is last parameter
1.61 paf 73: Value& vfilename=params->get_no_junction(params->size()-1,
74: "file name must not be code");
1.44 paf 75:
76: // loading text
1.61 paf 77: char *data=file_read_text(pool, r.absolute(vfilename.as_string()));
1.44 paf 78:
1.1 paf 79: // parse columns
80: Array *columns;
81: #ifndef NO_STRING_ORIGIN
82: const Origin& origin=method_name.origin();
1.2 paf 83: const char *file=origin.file;
1.1 paf 84: uint line=origin.line;
85: #endif
86: if(params->size()==2) {
87: columns=0;
88: } else {
89: columns=new(pool) Array(pool);
90:
91: if(char *row_chars=getrow(&data))
92: do {
93: String *name=new(pool) String(pool);
1.45 paf 94: name->APPEND_TAINTED(lsplit(&row_chars, '\t'), 0, file, line++);
1.1 paf 95: *columns+=name;
96: } while(row_chars);
97: }
98:
99: // parse cells
1.27 paf 100: Table& table=*new(pool) Table(pool, &method_name, columns);
1.1 paf 101: char *row_chars;
102: while(row_chars=getrow(&data)) {
1.28 paf 103: if(!*row_chars) // remove empty lines
104: continue;
1.1 paf 105: Array *row=new(pool) Array(pool);
106: while(char *cell_chars=lsplit(&row_chars, '\t')) {
107: String *cell=new(pool) String(pool);
1.44 paf 108: cell->APPEND_TAINTED(cell_chars, 0, file, line);
1.1 paf 109: *row+=cell;
110: }
111: line++;
112: table+=row;
113: };
114:
115: // replace any previous table value
1.18 paf 116: static_cast<VTable *>(r.self)->set_table(table);
1.1 paf 117: }
1.2 paf 118:
1.61 paf 119: static void _save(Request& r, const String& method_name, MethodParams *params) {
1.22 paf 120: Pool& pool=r.pool();
1.61 paf 121: Value& vtable_name=params->get_no_junction(params->size()-1,
122: "file name must not be code");
1.22 paf 123:
1.31 paf 124: Table& table=static_cast<VTable *>(r.self)->table();
125:
126: String sdata(pool);
127: if(params->size()==1) { // not nameless=named output
128: // write out names line
129: if(table.columns()) { // named table
130: for(int column=0; column<table.columns()->size(); column++) {
131: if(column)
132: sdata.APPEND_CONST("\t");
133: sdata.append(*static_cast<String *>(table.columns()->quick_get(column)),
134: String::UL_TABLE);
135: }
136: } else { // nameless table
137: int lsize=table.size()?static_cast<Array *>(table.get(0))->size():0;
138: if(lsize)
139: for(int column=0; column<lsize; column++) {
140: char *cindex_tab=(char *)malloc(MAX_NUMBER);
141: snprintf(cindex_tab, MAX_NUMBER, "%d\t", column);
142: sdata.APPEND_CONST(cindex_tab);
143: }
144: else
145: sdata.APPEND_CONST("empty nameless table");
146: }
147: sdata.APPEND_CONST("\n");
148: }
149: // data lines
150: for(int index=0; index<table.size(); index++) {
151: Array *row=static_cast<Array *>(table.quick_get(index));
152: for(int column=0; column<row->size(); column++) {
153: if(column)
154: sdata.APPEND_CONST("\t");
155: sdata.append(*static_cast<String *>(row->quick_get(column)),
156: String::UL_TABLE);
157: }
158: sdata.APPEND_CONST("\n");
159: }
160:
161: // write
1.61 paf 162: file_write(pool, r.absolute(vtable_name.as_string()),
1.48 paf 163: sdata.cstr(), sdata.size(), true);
1.22 paf 164: }
165:
1.61 paf 166: static void _count(Request& r, const String&, MethodParams *) {
1.6 paf 167: Pool& pool=r.pool();
1.18 paf 168: Value& value=*new(pool) VInt(pool, static_cast<VTable *>(r.self)->table().size());
1.15 paf 169: r.write_no_lang(value);
1.6 paf 170: }
171:
1.61 paf 172: static void _line(Request& r, const String& method_name, MethodParams *) {
1.6 paf 173: Pool& pool=r.pool();
1.37 paf 174: Value& value=*new(pool) VInt(pool, 1+static_cast<VTable *>(r.self)->table().current());
1.15 paf 175: r.write_no_lang(value);
1.6 paf 176: }
177:
1.61 paf 178: static void _offset(Request& r, const String& method_name, MethodParams *params) {
1.6 paf 179: Pool& pool=r.pool();
1.18 paf 180: Table& table=static_cast<VTable *>(r.self)->table();
1.37 paf 181: if(params->size())
1.61 paf 182: table.shift((int)r.process(params->get(0)).as_double());
1.37 paf 183: else {
184: Value& value=*new(pool) VInt(pool, table.current());
1.15 paf 185: r.write_no_lang(value);
1.6 paf 186: }
187: }
188:
1.54 paf 189: /// @test $a.menu{ $a[123] }
1.61 paf 190: static void _menu(Request& r, const String& method_name, MethodParams *params) {
191: Value& body_code=params->get_junction(0, "body must be code");
1.7 paf 192:
1.61 paf 193: Value *delim_code=params->size()==2?¶ms->get(1):0;
1.7 paf 194:
1.18 paf 195: Table& table=static_cast<VTable *>(r.self)->table();
1.7 paf 196: bool need_delim=false;
1.37 paf 197: int saved_current=table.current();
1.22 paf 198: for(int row=0; row<table.size(); row++) {
199: table.set_current(row);
1.7 paf 200:
1.12 paf 201: Value& processed_body=r.process(body_code);
1.7 paf 202: if(delim_code) { // delimiter set?
203: const String *string=processed_body.get_string();
204: if(need_delim && string && string->size()) // need delim & iteration produced string?
205: r.write_pass_lang(r.process(*delim_code));
206: need_delim=true;
207: }
208: r.write_pass_lang(processed_body);
209: }
1.37 paf 210: table.set_current(saved_current);
1.7 paf 211: }
212:
1.61 paf 213: static void _empty(Request& r, const String& method_name, MethodParams *params) {
1.18 paf 214: Table& table=static_cast<VTable *>(r.self)->table();
1.61 paf 215: if(table.size()==0)
1.62 ! paf 216: r.write_pass_lang(r.process(params->get(0)));
! 217: else if(params->size()>1)
! 218: r.write_pass_lang(r.process(params->get(1)));
1.8 paf 219: }
1.15 paf 220:
1.29 paf 221: struct Record_info {
222: Pool *pool;
223: Table *table;
224: Hash *hash;
225: };
226: static void store_column_item_to_hash(Array::Item *item, void *info) {
227: Record_info& ri=*static_cast<Record_info *>(info);
228: String& column_name=*static_cast<String *>(item);
229: const String *column_item=ri.table->item(column_name);
230: Value *value;
231: if(column_item)
232: value=new(*ri.pool) VString(*column_item);
233: else
234: value=new(*ri.pool) VUnknown(*ri.pool);
235: ri.hash->put(column_name, value);
236: }
1.61 paf 237: static void _record(Request& r, const String& method_name, MethodParams *params) {
1.29 paf 238: Table& table=static_cast<VTable *>(r.self)->table();
239: if(const Array *columns=table.columns()) {
240: Pool& pool=r.pool();
241: Value& value=*new(pool) VHash(pool);
242: Record_info record_info={&pool, &table, value.get_hash()};
243: columns->for_each(store_column_item_to_hash, &record_info);
244:
245: r.write_no_lang(value);
246: }
247: }
248:
1.34 paf 249: struct Seq_item {
250: Array *row;
251: union {
252: char *c_str;
253: double d;
254: } value;
1.32 paf 255: };
1.34 paf 256: static int sort_cmp_string(const void *a, const void *b) {
257: return strcmp(
258: static_cast<const Seq_item *>(a)->value.c_str,
259: static_cast<const Seq_item *>(b)->value.c_str
260: );
261: }
262: static int sort_cmp_double(const void *a, const void *b) {
263: double va=static_cast<const Seq_item *>(a)->value.d;
264: double vb=static_cast<const Seq_item *>(b)->value.d;
265: if(va<vb)
266: return -1;
267: else if(va>vb)
268: return +1;
269: else
270: return 0;
271: }
1.61 paf 272: static void _sort(Request& r, const String& method_name, MethodParams *params) {
273: Value& key_maker=params->get_junction(0, "key-maker must be code");
274:
275: bool reverse=params->size()==2/*..[asc|desc]*/?
276: reverse=params->get_no_junction(1, "order must not be code").as_string()=="desc":
277: false;
1.32 paf 278:
279: Table& table=static_cast<VTable *>(r.self)->table();
1.34 paf 280:
281: // anything to sort?
282: if(!table.size())
283: return;
284:
285: Seq_item *seq=(Seq_item *)malloc(sizeof(Seq_item)*table.size());
286: int i;
287:
288: // calculate key values
289: bool key_values_are_strings=true;
290: for(i=0; i<table.size(); i++) {
1.32 paf 291: table.set_current(i);
292: // calculate key value
1.61 paf 293: seq[i].row=(MethodParams *)table.get(i);
1.34 paf 294: Value& value=*r.process(key_maker).as_expr_result(true/*return string as-is*/);
295: if(i==0) // determining key values type by first one
296: key_values_are_strings=value.is_string();
297:
298: if(key_values_are_strings)
299: seq[i].value.c_str=value.as_string().cstr();
300: else
301: seq[i].value.d=value.as_double();
1.32 paf 302: }
303: // sort keys
1.34 paf 304: _qsort(seq, table.size(), sizeof(Seq_item),
305: key_values_are_strings?sort_cmp_string:sort_cmp_double);
1.32 paf 306:
1.34 paf 307: // reorder table as they require in 'seq'
308: for(i=0; i<table.size(); i++)
309: table.put(i, seq[reverse?table.size()-1-i:i].row);
1.32 paf 310:
1.34 paf 311: // reset 'current'
1.32 paf 312: table.set_current(0);
313: }
314:
1.61 paf 315: static void _locate(Request& r, const String& method_name, MethodParams *params) {
1.36 paf 316: VTable& vtable=*static_cast<VTable *>(r.self);
317: Table& table=vtable.table();
318: vtable.last_locate_was_successful=table.locate(
1.61 paf 319: params->get(0).as_string(),
320: params->get(1).as_string());
1.36 paf 321: }
322:
1.61 paf 323: static void _found(Request& r, const String& method_name, MethodParams *params) {
324: if(static_cast<VTable *>(r.self)->last_locate_was_successful)
325: r.write_pass_lang(r.process(params->get_junction(0, "found-parameter must be code")));
326: else if(params->size()==2)
327: r.write_pass_lang(r.process(params->get_junction(0, "else-parameter must be code")));
1.37 paf 328: }
329:
1.61 paf 330: static void _flip(Request& r, const String& method_name, MethodParams *params) {
1.39 paf 331: Pool& pool=r.pool();
332: VTable& vtable=*static_cast<VTable *>(r.self);
333:
334: Table& old_table=*vtable.get_table();
335: Table& new_table=*new(pool) Table(pool, &method_name, 0/*nameless*/);
336: if(old_table.size())
337: if(int old_cols=old_table.at(0).size())
338: for(int column=0; column<old_cols; column++) {
339: Array& new_row=*new(pool) Array(pool, old_table.size());
340: for(int i=0; i<old_table.size(); i++) {
341: const Array& old_row=old_table.at(i);
342: new_row+=column<old_row.size()?old_row.get(column):empty_string;
343: }
344: new_table+=&new_row;
345: }
346:
347: vtable.set_table(new_table);
348: }
349:
1.61 paf 350: static void _append(Request& r, const String& method_name, MethodParams *params) {
1.41 paf 351: Pool& pool=r.pool();
352: // data is last parameter
1.61 paf 353: const String& string=
354: r.process(params->get_junction(0, "body must be code")).as_string();
1.41 paf 355:
356: // parse cells
357: Array& row=*new(pool) Array(pool);
1.46 paf 358: string.split(row, 0, "\t", 1, String::UL_CLEAN);
1.41 paf 359:
360: static_cast<VTable *>(r.self)->table()+=&row;
361: }
362:
1.61 paf 363: static void _join(Request& r, const String& method_name, MethodParams *params) {
1.42 paf 364: Pool& pool=r.pool();
365:
1.61 paf 366: Table *maybe_src=params->get_no_junction(0, "table ref must not be code").get_table();
1.42 paf 367: if(!maybe_src)
1.49 paf 368: PTHROW(0, 0,
1.42 paf 369: &method_name,
370: "source is not a table");
371:
372: Table& src=*maybe_src;
373: Table& dest=static_cast<VTable *>(r.self)->table();
374: if(&src == &dest)
1.49 paf 375: PTHROW(0, 0,
1.42 paf 376: &method_name,
377: "source and destination are same table");
378:
379: if(const Array *dest_columns=dest.columns()) { // dest is named
380: int saved_src_current=src.current();
381: for(int src_row=0; src_row<src.size(); src_row++) {
382: src.set_current(src_row);
383: Array& dest_row=*new(pool) Array(pool);
384: for(int dest_column=0; dest_column<dest_columns->size(); dest_column++)
385: dest_row+=src.item(*dest_columns->get_string(dest_column));
386: dest+=&dest_row;
387: }
388: src.set_current(saved_src_current);
389: } else { // dest is nameless
390: for(int src_row=0; src_row<src.size(); src_row++)
391: dest+=&src.at(src_row);
392: }
393: }
394:
1.57 paf 395: /// ^table:sql{query}[(count[;offset])]
1.61 paf 396: static void _sql(Request& r, const String& method_name, MethodParams *params) {
1.49 paf 397: Pool& pool=r.pool();
398:
399: if(!r.connection)
400: PTHROW(0, 0,
401: &method_name,
402: "without connect");
403:
1.61 paf 404: Value& statement=params->get_junction(0, "statement must be code");
1.49 paf 405:
1.53 paf 406: ulong limit=0;
1.49 paf 407: if(params->size()>1) {
1.61 paf 408: Value& limit_code=params->get_junction(1, "limit must be expression");
1.53 paf 409: limit=(uint)r.process(limit_code).as_double();
1.49 paf 410: }
411:
1.51 paf 412: ulong offset=0;
1.49 paf 413: if(params->size()>2) {
1.61 paf 414: Value& offset_code=params->get_junction(2, "offset must be expression");
1.51 paf 415: offset=(ulong)r.process(offset_code).as_double();
1.49 paf 416: }
417:
1.54 paf 418: Temp_lang temp_lang(r, String::UL_SQL);
419: const String& statement_string=r.process(statement).as_string();
1.55 paf 420: const char *statement_cstr=
421: statement_string.cstr(String::UL_UNSPECIFIED, r.connection);
1.51 paf 422: unsigned int sql_column_count; SQL_Driver::Cell *sql_columns;
423: unsigned long sql_row_count; SQL_Driver::Cell **sql_rows;
1.52 paf 424: bool need_rethrow=false; Exception rethrow_me;
425: PTRY {
426: r.connection->query(
1.53 paf 427: statement_cstr, offset, limit,
1.52 paf 428: &sql_column_count, &sql_columns,
429: &sql_row_count, &sql_rows);
430: }
431: PCATCH(e) { // connect/process problem
432: rethrow_me=e; need_rethrow=true;
433: }
434: PEND_CATCH
435: if(need_rethrow)
436: PTHROW(rethrow_me.type(), rethrow_me.code(),
1.53 paf 437: &statement_string, // setting more specific source [were url]
1.52 paf 438: rethrow_me.comment());
1.51 paf 439:
440: Array& table_columns=*new(pool) Array(pool);
441: for(unsigned int i=0; i<sql_column_count; i++) {
442: String& table_column=*new(pool) String(pool);
443: table_column.APPEND_TAINTED(
444: (const char *)sql_columns[i].ptr, sql_columns[i].size,
445: statement_cstr, 0);
446: table_columns+=&table_column;
447: }
448:
449: Table& table=*new(pool) Table(pool, &method_name, &table_columns);
450:
451: {
452: for(unsigned long r=0; r<sql_row_count; r++) {
453: SQL_Driver::Cell *sql_cells=sql_rows[r];
454: Array& table_row=*new(pool) Array(pool);
455:
456: for(unsigned int i=0; i<sql_column_count; i++) {
457: String& table_cell=*new(pool) String(pool);
458: table_cell.APPEND_TAINTED(
459: (const char *)sql_cells[i].ptr, sql_cells[i].size,
460: statement_cstr, r);
461: table_row+=&table_cell;
462: }
463: table+=&table_row;
464: }
465: }
1.49 paf 466:
467: // replace any previous table value
468: static_cast<VTable *>(r.self)->set_table(table);
469: }
470:
1.58 paf 471: /// ^table:dir[path]
472: /// ^table:dir[path][regexp]
1.61 paf 473: static void _dir(Request& r, const String& method_name, MethodParams *params) {
1.58 paf 474: Pool& pool=r.pool();
475:
1.61 paf 476: Value& relative_path=params->get_no_junction(0, "path must not be code");
1.58 paf 477:
1.59 paf 478: const String *regexp;
479: pcre *regexp_code;
480: int ovecsize;
481: int *ovector;
482: if(params->size()>1) {
1.61 paf 483: regexp=¶ms->get_no_junction(1, "regexp must not be code").as_string();
1.59 paf 484:
485: const char *pattern=regexp->cstr(String::UL_AS_IS);
486: const char *errptr;
487: int erroffset;
488: regexp_code=pcre_compile(pattern, PCRE_EXTRA | PCRE_DOTALL,
489: &errptr, &erroffset,
490: pcre_tables);
491:
492: if(!regexp_code)
493: PTHROW(0, 0,
494: ®exp->mid(erroffset, regexp->size()),
495: "regular expression syntax error - %s", errptr);
496:
497: ovector=(int *)malloc(sizeof(int)*(ovecsize=(1/*match*/)*3));
498: } else
499: regexp_code=0;
500:
501:
1.58 paf 502: const char* absolute_path_cstr=r.absolute(relative_path.as_string())
503: .cstr(String::UL_FILE_NAME);
504:
505: Array& columns=*new(pool) Array(pool);
506: columns+=new(pool) String(pool, "name");
507: Table& table=*new(pool) Table(pool, &method_name, &columns);
508:
509: LOAD_DIR(absolute_path_cstr,
510: size_t file_name_size=strlen(ffblk.ff_name);
1.59 paf 511: bool suits=true;
512: if(regexp_code) {
513: int exec_result=pcre_exec(regexp_code, 0,
514: ffblk.ff_name, file_name_size, 0,
515: 0, ovector, ovecsize);
516:
517: if(exec_result==PCRE_ERROR_NOMATCH)
518: suits=false;
519: else if(exec_result<0) {
520: (*pcre_free)(regexp_code);
521: PTHROW(0, 0,
522: regexp,
1.60 paf 523: "regular expression execute (%d)",
1.59 paf 524: exec_result);
525: }
526: }
527:
528: if(suits) {
529: char *file_name_cstr=(char *)r.malloc(file_name_size);
530: memcpy(file_name_cstr, ffblk.ff_name, file_name_size);
531: String &file_name=*new(pool) String(pool);
532: file_name.APPEND_TAINTED(file_name_cstr, file_name_size,
533: method_name.origin().file, method_name.origin().line);
534:
535: Array& row=*new(pool) Array(pool);
536: row+=&file_name;
537: table+=&row;
538: }
1.58 paf 539: );
1.59 paf 540:
541: if(regexp_code)
542: (*pcre_free)(regexp_code);
1.58 paf 543:
544: // replace any previous table value
545: static_cast<VTable *>(r.self)->set_table(table);
546: }
547:
1.15 paf 548: // initialize
1.14 paf 549: void initialize_table_class(Pool& pool, VStateless_class& vclass) {
1.49 paf 550: // ^table:set{data}
551: // ^table:set[nameless]{data}
1.40 paf 552: vclass.add_native_method("set", Method::CT_DYNAMIC, _set, 1, 2);
1.2 paf 553:
1.49 paf 554: // ^table:load[file]
555: // ^table:load[nameless;file]
1.40 paf 556: vclass.add_native_method("load", Method::CT_DYNAMIC, _load, 1, 2);
1.22 paf 557:
558: // ^table.save[file]
559: // ^table.save[nameless;file]
1.40 paf 560: vclass.add_native_method("save", Method::CT_DYNAMIC, _save, 1, 2);
1.6 paf 561:
562: // ^table.count[]
1.40 paf 563: vclass.add_native_method("count", Method::CT_DYNAMIC, _count, 0, 0);
1.6 paf 564:
565: // ^table.line[]
1.40 paf 566: vclass.add_native_method("line", Method::CT_DYNAMIC, _line, 0, 0);
1.6 paf 567:
1.10 paf 568: // ^table.offset[]
569: // ^table.offset[offset]
1.40 paf 570: vclass.add_native_method("offset", Method::CT_DYNAMIC, _offset, 0, 1);
1.7 paf 571:
1.10 paf 572: // ^table.menu{code}
573: // ^table.menu{code}[delim]
1.40 paf 574: vclass.add_native_method("menu", Method::CT_DYNAMIC, _menu, 1, 2);
1.8 paf 575:
1.10 paf 576: // ^table.empty{code-when-empty}
577: // ^table.empty{code-when-empty}{code-when-not}
1.40 paf 578: vclass.add_native_method("empty", Method::CT_DYNAMIC, _empty, 1, 2);
1.29 paf 579:
580: // ^table.record[]
1.40 paf 581: vclass.add_native_method("record", Method::CT_DYNAMIC, _record, 0, 0);
1.32 paf 582:
583: // ^table.sort{string-key-maker} ^table.sort{string-key-maker}[asc|desc]
584: // ^table.sort(numeric-key-maker) ^table.sort(numeric-key-maker)[asc|desc]
1.40 paf 585: vclass.add_native_method("sort", Method::CT_DYNAMIC, _sort, 1, 2);
1.8 paf 586:
1.36 paf 587: // ^table.locate[field;value]
1.40 paf 588: vclass.add_native_method("locate", Method::CT_DYNAMIC, _locate, 2, 2);
1.37 paf 589: // ^table.found{when-found}
590: // ^table.found{when-found}{when-not-found}
1.40 paf 591: vclass.add_native_method("found", Method::CT_DYNAMIC, _found, 1, 2);
1.39 paf 592:
593: // ^table.flip[]
1.40 paf 594: vclass.add_native_method("flip", Method::CT_DYNAMIC, _flip, 0, 0);
1.41 paf 595:
596: // ^table.append{r{tab}e{tab}c{tab}o{tab}r{tab}d}
597: vclass.add_native_method("append", Method::CT_DYNAMIC, _append, 1, 1);
1.42 paf 598:
599: // ^table.join[table]
600: vclass.add_native_method("join", Method::CT_DYNAMIC, _join, 1, 1);
1.49 paf 601:
602:
1.51 paf 603: // ^table:sql[query][(count[;offset])]
1.49 paf 604: vclass.add_native_method("sql", Method::CT_DYNAMIC, _sql, 1, 3);
1.58 paf 605:
606: // ^table:dir[path]
607: // ^table:dir[path][regexp]
608: vclass.add_native_method("dir", Method::CT_DYNAMIC, _dir, 1, 2);
1.40 paf 609: }
E-mail: