Annotation of parser3/src/classes/table.C, revision 1.65
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.65 ! paf 8: $Id: table.C,v 1.64 2001/04/23 10:58:27 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.61 paf 189: static void _menu(Request& r, const String& method_name, MethodParams *params) {
190: Value& body_code=params->get_junction(0, "body must be code");
1.7 paf 191:
1.61 paf 192: Value *delim_code=params->size()==2?¶ms->get(1):0;
1.7 paf 193:
1.64 paf 194: VTable& vtable=*static_cast<VTable *>(r.self);
195: Table& table=vtable.table();
1.7 paf 196: bool need_delim=false;
1.64 paf 197: vtable.lock(); 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.64 paf 210: table.set_current(saved_current); vtable.unlock();
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.65 ! paf 221: /// used by table: _record / store_column_item_to_hash
1.29 paf 222: struct Record_info {
223: Pool *pool;
224: Table *table;
225: Hash *hash;
226: };
227: static void store_column_item_to_hash(Array::Item *item, void *info) {
228: Record_info& ri=*static_cast<Record_info *>(info);
229: String& column_name=*static_cast<String *>(item);
230: const String *column_item=ri.table->item(column_name);
231: Value *value;
232: if(column_item)
233: value=new(*ri.pool) VString(*column_item);
234: else
235: value=new(*ri.pool) VUnknown(*ri.pool);
236: ri.hash->put(column_name, value);
237: }
1.61 paf 238: static void _record(Request& r, const String& method_name, MethodParams *params) {
1.29 paf 239: Table& table=static_cast<VTable *>(r.self)->table();
240: if(const Array *columns=table.columns()) {
241: Pool& pool=r.pool();
242: Value& value=*new(pool) VHash(pool);
243: Record_info record_info={&pool, &table, value.get_hash()};
244: columns->for_each(store_column_item_to_hash, &record_info);
245:
246: r.write_no_lang(value);
247: }
248: }
249:
1.34 paf 250: struct Seq_item {
251: Array *row;
252: union {
253: char *c_str;
254: double d;
255: } value;
1.32 paf 256: };
1.34 paf 257: static int sort_cmp_string(const void *a, const void *b) {
258: return strcmp(
259: static_cast<const Seq_item *>(a)->value.c_str,
260: static_cast<const Seq_item *>(b)->value.c_str
261: );
262: }
263: static int sort_cmp_double(const void *a, const void *b) {
264: double va=static_cast<const Seq_item *>(a)->value.d;
265: double vb=static_cast<const Seq_item *>(b)->value.d;
266: if(va<vb)
267: return -1;
268: else if(va>vb)
269: return +1;
270: else
271: return 0;
272: }
1.61 paf 273: static void _sort(Request& r, const String& method_name, MethodParams *params) {
274: Value& key_maker=params->get_junction(0, "key-maker must be code");
275:
276: bool reverse=params->size()==2/*..[asc|desc]*/?
277: reverse=params->get_no_junction(1, "order must not be code").as_string()=="desc":
278: false;
1.32 paf 279:
280: Table& table=static_cast<VTable *>(r.self)->table();
1.34 paf 281:
282: // anything to sort?
283: if(!table.size())
284: return;
285:
286: Seq_item *seq=(Seq_item *)malloc(sizeof(Seq_item)*table.size());
287: int i;
288:
289: // calculate key values
290: bool key_values_are_strings=true;
291: for(i=0; i<table.size(); i++) {
1.32 paf 292: table.set_current(i);
293: // calculate key value
1.61 paf 294: seq[i].row=(MethodParams *)table.get(i);
1.34 paf 295: Value& value=*r.process(key_maker).as_expr_result(true/*return string as-is*/);
296: if(i==0) // determining key values type by first one
297: key_values_are_strings=value.is_string();
298:
299: if(key_values_are_strings)
300: seq[i].value.c_str=value.as_string().cstr();
301: else
302: seq[i].value.d=value.as_double();
1.32 paf 303: }
304: // sort keys
1.34 paf 305: _qsort(seq, table.size(), sizeof(Seq_item),
306: key_values_are_strings?sort_cmp_string:sort_cmp_double);
1.32 paf 307:
1.34 paf 308: // reorder table as they require in 'seq'
309: for(i=0; i<table.size(); i++)
310: table.put(i, seq[reverse?table.size()-1-i:i].row);
1.32 paf 311:
1.34 paf 312: // reset 'current'
1.32 paf 313: table.set_current(0);
314: }
315:
1.61 paf 316: static void _locate(Request& r, const String& method_name, MethodParams *params) {
1.36 paf 317: VTable& vtable=*static_cast<VTable *>(r.self);
318: Table& table=vtable.table();
319: vtable.last_locate_was_successful=table.locate(
1.61 paf 320: params->get(0).as_string(),
321: params->get(1).as_string());
1.36 paf 322: }
323:
1.61 paf 324: static void _found(Request& r, const String& method_name, MethodParams *params) {
325: if(static_cast<VTable *>(r.self)->last_locate_was_successful)
326: r.write_pass_lang(r.process(params->get_junction(0, "found-parameter must be code")));
327: else if(params->size()==2)
328: r.write_pass_lang(r.process(params->get_junction(0, "else-parameter must be code")));
1.37 paf 329: }
330:
1.61 paf 331: static void _flip(Request& r, const String& method_name, MethodParams *params) {
1.39 paf 332: Pool& pool=r.pool();
333: VTable& vtable=*static_cast<VTable *>(r.self);
334:
335: Table& old_table=*vtable.get_table();
336: Table& new_table=*new(pool) Table(pool, &method_name, 0/*nameless*/);
337: if(old_table.size())
338: if(int old_cols=old_table.at(0).size())
339: for(int column=0; column<old_cols; column++) {
340: Array& new_row=*new(pool) Array(pool, old_table.size());
341: for(int i=0; i<old_table.size(); i++) {
342: const Array& old_row=old_table.at(i);
343: new_row+=column<old_row.size()?old_row.get(column):empty_string;
344: }
345: new_table+=&new_row;
346: }
347:
348: vtable.set_table(new_table);
349: }
350:
1.61 paf 351: static void _append(Request& r, const String& method_name, MethodParams *params) {
1.41 paf 352: Pool& pool=r.pool();
353: // data is last parameter
1.61 paf 354: const String& string=
355: r.process(params->get_junction(0, "body must be code")).as_string();
1.41 paf 356:
357: // parse cells
358: Array& row=*new(pool) Array(pool);
1.46 paf 359: string.split(row, 0, "\t", 1, String::UL_CLEAN);
1.41 paf 360:
361: static_cast<VTable *>(r.self)->table()+=&row;
362: }
363:
1.61 paf 364: static void _join(Request& r, const String& method_name, MethodParams *params) {
1.42 paf 365: Pool& pool=r.pool();
366:
1.61 paf 367: Table *maybe_src=params->get_no_junction(0, "table ref must not be code").get_table();
1.42 paf 368: if(!maybe_src)
1.49 paf 369: PTHROW(0, 0,
1.42 paf 370: &method_name,
371: "source is not a table");
372:
373: Table& src=*maybe_src;
374: Table& dest=static_cast<VTable *>(r.self)->table();
375: if(&src == &dest)
1.49 paf 376: PTHROW(0, 0,
1.42 paf 377: &method_name,
378: "source and destination are same table");
379:
380: if(const Array *dest_columns=dest.columns()) { // dest is named
381: int saved_src_current=src.current();
382: for(int src_row=0; src_row<src.size(); src_row++) {
383: src.set_current(src_row);
384: Array& dest_row=*new(pool) Array(pool);
385: for(int dest_column=0; dest_column<dest_columns->size(); dest_column++)
386: dest_row+=src.item(*dest_columns->get_string(dest_column));
387: dest+=&dest_row;
388: }
389: src.set_current(saved_src_current);
390: } else { // dest is nameless
391: for(int src_row=0; src_row<src.size(); src_row++)
392: dest+=&src.at(src_row);
393: }
394: }
395:
1.57 paf 396: /// ^table:sql{query}[(count[;offset])]
1.61 paf 397: static void _sql(Request& r, const String& method_name, MethodParams *params) {
1.49 paf 398: Pool& pool=r.pool();
399:
400: if(!r.connection)
401: PTHROW(0, 0,
402: &method_name,
403: "without connect");
404:
1.61 paf 405: Value& statement=params->get_junction(0, "statement must be code");
1.49 paf 406:
1.53 paf 407: ulong limit=0;
1.49 paf 408: if(params->size()>1) {
1.61 paf 409: Value& limit_code=params->get_junction(1, "limit must be expression");
1.53 paf 410: limit=(uint)r.process(limit_code).as_double();
1.49 paf 411: }
412:
1.51 paf 413: ulong offset=0;
1.49 paf 414: if(params->size()>2) {
1.61 paf 415: Value& offset_code=params->get_junction(2, "offset must be expression");
1.51 paf 416: offset=(ulong)r.process(offset_code).as_double();
1.49 paf 417: }
418:
1.54 paf 419: Temp_lang temp_lang(r, String::UL_SQL);
420: const String& statement_string=r.process(statement).as_string();
1.55 paf 421: const char *statement_cstr=
422: statement_string.cstr(String::UL_UNSPECIFIED, r.connection);
1.51 paf 423: unsigned int sql_column_count; SQL_Driver::Cell *sql_columns;
424: unsigned long sql_row_count; SQL_Driver::Cell **sql_rows;
1.52 paf 425: bool need_rethrow=false; Exception rethrow_me;
426: PTRY {
427: r.connection->query(
1.53 paf 428: statement_cstr, offset, limit,
1.52 paf 429: &sql_column_count, &sql_columns,
430: &sql_row_count, &sql_rows);
431: }
432: PCATCH(e) { // connect/process problem
433: rethrow_me=e; need_rethrow=true;
434: }
435: PEND_CATCH
436: if(need_rethrow)
437: PTHROW(rethrow_me.type(), rethrow_me.code(),
1.53 paf 438: &statement_string, // setting more specific source [were url]
1.52 paf 439: rethrow_me.comment());
1.51 paf 440:
441: Array& table_columns=*new(pool) Array(pool);
442: for(unsigned int i=0; i<sql_column_count; i++) {
443: String& table_column=*new(pool) String(pool);
444: table_column.APPEND_TAINTED(
445: (const char *)sql_columns[i].ptr, sql_columns[i].size,
446: statement_cstr, 0);
447: table_columns+=&table_column;
448: }
449:
450: Table& table=*new(pool) Table(pool, &method_name, &table_columns);
451:
452: {
453: for(unsigned long r=0; r<sql_row_count; r++) {
454: SQL_Driver::Cell *sql_cells=sql_rows[r];
455: Array& table_row=*new(pool) Array(pool);
456:
457: for(unsigned int i=0; i<sql_column_count; i++) {
458: String& table_cell=*new(pool) String(pool);
459: table_cell.APPEND_TAINTED(
460: (const char *)sql_cells[i].ptr, sql_cells[i].size,
461: statement_cstr, r);
462: table_row+=&table_cell;
463: }
464: table+=&table_row;
465: }
466: }
1.49 paf 467:
468: // replace any previous table value
469: static_cast<VTable *>(r.self)->set_table(table);
470: }
471:
1.58 paf 472: /// ^table:dir[path]
473: /// ^table:dir[path][regexp]
1.61 paf 474: static void _dir(Request& r, const String& method_name, MethodParams *params) {
1.58 paf 475: Pool& pool=r.pool();
476:
1.61 paf 477: Value& relative_path=params->get_no_junction(0, "path must not be code");
1.58 paf 478:
1.59 paf 479: const String *regexp;
480: pcre *regexp_code;
481: int ovecsize;
482: int *ovector;
483: if(params->size()>1) {
1.61 paf 484: regexp=¶ms->get_no_junction(1, "regexp must not be code").as_string();
1.59 paf 485:
486: const char *pattern=regexp->cstr(String::UL_AS_IS);
487: const char *errptr;
488: int erroffset;
489: regexp_code=pcre_compile(pattern, PCRE_EXTRA | PCRE_DOTALL,
490: &errptr, &erroffset,
1.63 paf 491: r.pcre_tables);
1.59 paf 492:
493: if(!regexp_code)
494: PTHROW(0, 0,
495: ®exp->mid(erroffset, regexp->size()),
496: "regular expression syntax error - %s", errptr);
497:
498: ovector=(int *)malloc(sizeof(int)*(ovecsize=(1/*match*/)*3));
499: } else
500: regexp_code=0;
501:
502:
1.58 paf 503: const char* absolute_path_cstr=r.absolute(relative_path.as_string())
504: .cstr(String::UL_FILE_NAME);
505:
506: Array& columns=*new(pool) Array(pool);
507: columns+=new(pool) String(pool, "name");
508: Table& table=*new(pool) Table(pool, &method_name, &columns);
509:
510: LOAD_DIR(absolute_path_cstr,
511: size_t file_name_size=strlen(ffblk.ff_name);
1.59 paf 512: bool suits=true;
513: if(regexp_code) {
514: int exec_result=pcre_exec(regexp_code, 0,
515: ffblk.ff_name, file_name_size, 0,
516: 0, ovector, ovecsize);
517:
518: if(exec_result==PCRE_ERROR_NOMATCH)
519: suits=false;
520: else if(exec_result<0) {
521: (*pcre_free)(regexp_code);
522: PTHROW(0, 0,
523: regexp,
1.60 paf 524: "regular expression execute (%d)",
1.59 paf 525: exec_result);
526: }
527: }
528:
529: if(suits) {
530: char *file_name_cstr=(char *)r.malloc(file_name_size);
531: memcpy(file_name_cstr, ffblk.ff_name, file_name_size);
532: String &file_name=*new(pool) String(pool);
533: file_name.APPEND_TAINTED(file_name_cstr, file_name_size,
534: method_name.origin().file, method_name.origin().line);
535:
536: Array& row=*new(pool) Array(pool);
537: row+=&file_name;
538: table+=&row;
539: }
1.58 paf 540: );
1.59 paf 541:
542: if(regexp_code)
543: (*pcre_free)(regexp_code);
1.58 paf 544:
545: // replace any previous table value
546: static_cast<VTable *>(r.self)->set_table(table);
547: }
548:
1.15 paf 549: // initialize
1.14 paf 550: void initialize_table_class(Pool& pool, VStateless_class& vclass) {
1.49 paf 551: // ^table:set{data}
552: // ^table:set[nameless]{data}
1.40 paf 553: vclass.add_native_method("set", Method::CT_DYNAMIC, _set, 1, 2);
1.2 paf 554:
1.49 paf 555: // ^table:load[file]
556: // ^table:load[nameless;file]
1.40 paf 557: vclass.add_native_method("load", Method::CT_DYNAMIC, _load, 1, 2);
1.22 paf 558:
559: // ^table.save[file]
560: // ^table.save[nameless;file]
1.40 paf 561: vclass.add_native_method("save", Method::CT_DYNAMIC, _save, 1, 2);
1.6 paf 562:
563: // ^table.count[]
1.40 paf 564: vclass.add_native_method("count", Method::CT_DYNAMIC, _count, 0, 0);
1.6 paf 565:
566: // ^table.line[]
1.40 paf 567: vclass.add_native_method("line", Method::CT_DYNAMIC, _line, 0, 0);
1.6 paf 568:
1.10 paf 569: // ^table.offset[]
570: // ^table.offset[offset]
1.40 paf 571: vclass.add_native_method("offset", Method::CT_DYNAMIC, _offset, 0, 1);
1.7 paf 572:
1.10 paf 573: // ^table.menu{code}
574: // ^table.menu{code}[delim]
1.40 paf 575: vclass.add_native_method("menu", Method::CT_DYNAMIC, _menu, 1, 2);
1.8 paf 576:
1.10 paf 577: // ^table.empty{code-when-empty}
578: // ^table.empty{code-when-empty}{code-when-not}
1.40 paf 579: vclass.add_native_method("empty", Method::CT_DYNAMIC, _empty, 1, 2);
1.29 paf 580:
581: // ^table.record[]
1.40 paf 582: vclass.add_native_method("record", Method::CT_DYNAMIC, _record, 0, 0);
1.32 paf 583:
584: // ^table.sort{string-key-maker} ^table.sort{string-key-maker}[asc|desc]
585: // ^table.sort(numeric-key-maker) ^table.sort(numeric-key-maker)[asc|desc]
1.40 paf 586: vclass.add_native_method("sort", Method::CT_DYNAMIC, _sort, 1, 2);
1.8 paf 587:
1.36 paf 588: // ^table.locate[field;value]
1.40 paf 589: vclass.add_native_method("locate", Method::CT_DYNAMIC, _locate, 2, 2);
1.37 paf 590: // ^table.found{when-found}
591: // ^table.found{when-found}{when-not-found}
1.40 paf 592: vclass.add_native_method("found", Method::CT_DYNAMIC, _found, 1, 2);
1.39 paf 593:
594: // ^table.flip[]
1.40 paf 595: vclass.add_native_method("flip", Method::CT_DYNAMIC, _flip, 0, 0);
1.41 paf 596:
597: // ^table.append{r{tab}e{tab}c{tab}o{tab}r{tab}d}
598: vclass.add_native_method("append", Method::CT_DYNAMIC, _append, 1, 1);
1.42 paf 599:
600: // ^table.join[table]
601: vclass.add_native_method("join", Method::CT_DYNAMIC, _join, 1, 1);
1.49 paf 602:
603:
1.51 paf 604: // ^table:sql[query][(count[;offset])]
1.49 paf 605: vclass.add_native_method("sql", Method::CT_DYNAMIC, _sql, 1, 3);
1.58 paf 606:
607: // ^table:dir[path]
608: // ^table:dir[path][regexp]
609: vclass.add_native_method("dir", Method::CT_DYNAMIC, _dir, 1, 2);
1.40 paf 610: }
E-mail: