--- parser3/src/classes/table.C 2001/09/07 12:46:19 1.111 +++ parser3/src/classes/table.C 2001/10/02 15:40:32 1.118 @@ -2,10 +2,10 @@ Parser: @b table parser class. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + + $Id: table.C,v 1.118 2001/10/02 15:40:32 parser Exp $ */ -static const char *RCSId="$Id: table.C,v 1.111 2001/09/07 12:46:19 parser Exp $"; #include "classes.h" #include "pa_config_includes.h" @@ -65,7 +65,7 @@ static void _set(Request& r, const Strin while(i.has_next()) { Array& row=*new(pool) Array(pool); const String& string=*i.next_string(); - // remove empty lines + // remove comment lines if(!string.size()) continue; @@ -80,11 +80,11 @@ static void _set(Request& r, const Strin static void _load(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); // filename is last parameter - const String& filename=params->as_string(params->size()-1, + Value& vfilename=params->as_no_junction(params->size()-1, "file name must not be code"); // loading text - char *data=file_read_text(pool, r.absolute(filename)); + char *data=file_read_text(pool, r.absolute(vfilename.as_string())); // parse columns Array *columns; @@ -110,7 +110,8 @@ static void _load(Request& r, const Stri Table& table=*new(pool) Table(pool, &method_name, columns); char *row_chars; while(row_chars=getrow(&data)) { - if(!*row_chars) // remove empty lines + // remove empty&comment lines + if(!*row_chars || *row_chars == '#') continue; Array *row=new(pool) Array(pool); while(char *cell_chars=lsplit(&row_chars, '\t')) { @@ -342,13 +343,6 @@ static void _menu(Request& r, const Stri table.set_current(saved_current); } -static void _empty(Request& r, const String& method_name, MethodParams *params) { - Pool& pool=r.pool(); - Table& table=static_cast(r.self)->table(); - - r.write_no_lang(*new(pool) VBool(pool, table.size()==0)); -} - #ifndef DOXYGEN struct Row_info { Table *table; @@ -477,7 +471,8 @@ static void _sort(Request& r, const Stri for(i=0; i(r.self)->set_table(new_table); } static void _locate(Request& r, const String& method_name, MethodParams *params) { @@ -718,9 +713,6 @@ MTable::MTable(Pool& apool) : Methoded(a // ^table.menu{code}[delim] add_native_method("menu", Method::CT_DYNAMIC, _menu, 1, 2); - // ^table.empty[] - add_native_method("empty", Method::CT_DYNAMIC, _empty, 0, 0); - // ^table:hash[key field name] // ^table:hash[key field name][value field name;...] add_native_method("hash", Method::CT_DYNAMIC, _hash, 1, 1000);