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