|
|
| version 1.274, 2010/10/05 20:56:12 | version 1.276, 2010/10/21 15:06:29 |
|---|---|
| Line 27 static const char * const IDENT_TABLE_C= | Line 27 static const char * const IDENT_TABLE_C= |
| class MTable: public Methoded { | class MTable: public Methoded { |
| public: // VStateless_class | public: // VStateless_class |
| Value* create_new_value(Pool&) { return new VTable(); } | Value* create_new_value(Pool&) { return new VTable(); } |
| public: | public: |
| MTable(); | MTable(); |
| public: // Methoded | |
| bool used_directly() { return true; } | |
| }; | }; |
| // global variable | // global variable |
| Line 954 struct Expression_is_true_info { | Line 950 struct Expression_is_true_info { |
| Value* expression_code; | Value* expression_code; |
| }; | }; |
| #endif | #endif |
| static bool expression_is_true(Table&, Expression_is_true_info* info) { | static bool expression_is_true(Table&, Expression_is_true_info* info) { |
| return info->r->process_to_value(*info->expression_code).as_bool(); | return info->r->process_to_value(*info->expression_code).as_bool(); |
| } | } |
| static bool _locate_expression(Table& table, Table::Action_options o, | |
| Request& r, MethodParams& params) { | static bool _locate_expression(Table& table, Request& r, MethodParams& params) { |
| check_option_param(o.defined, params, 1, | |
| "locate by expression only has parameters: expression and, maybe, options"); | |
| Value& expression_code=params.as_junction(0, "must be expression"); | Value& expression_code=params.as_junction(0, "must be expression"); |
| const size_t options_index=1; | |
| Table::Action_options o=get_action_options(r, params, options_index, table); | |
| check_option_param(o.defined, params, options_index, "locate by expression only has parameters: expression and, maybe, options"); | |
| Expression_is_true_info info={&r, &expression_code}; | Expression_is_true_info info={&r, &expression_code}; |
| return table.table_first_that(expression_is_true, &info, o); | return table.table_first_that(expression_is_true, &info, o); |
| } | } |
| static bool _locate_name_value(Table& table, Table::Action_options o, | |
| Request&, MethodParams& params) { | static bool _locate_name_value(Table& table, Request& r, MethodParams& params) { |
| check_option_param(o.defined, params, 2, | |
| "locate by locate by name has parameters: name, value and, maybe, options"); | |
| const String& name=params.as_string(0, "column name must be string"); | const String& name=params.as_string(0, "column name must be string"); |
| const String& value=params.as_string(1, VALUE_MUST_BE_STRING); | const String& value=params.as_string(1, VALUE_MUST_BE_STRING); |
| const size_t options_index=2; | |
| Table::Action_options o=get_action_options(r, params, options_index, table); | |
| check_option_param(o.defined, params, options_index, "locate by name has parameters: name, value and, maybe, options"); | |
| return table.locate(name, value, o); | return table.locate(name, value, o); |
| } | } |
| static void _locate(Request& r, MethodParams& params) { | static void _locate(Request& r, MethodParams& params) { |
| Table& table=GET_SELF(r, VTable).table(); | Table& table=GET_SELF(r, VTable).table(); |
| Table::Action_options o=get_action_options(r, params, 1, table); | |
| bool result=params[0].get_junction()? | bool result=params[0].get_junction()? |
| _locate_expression(table, o, r, params) : | _locate_expression(table, r, params) : |
| _locate_name_value(table, o, r, params); | _locate_name_value(table, r, params); |
| r.write_no_lang(VBool::get(result)); | r.write_no_lang(VBool::get(result)); |
| } | } |