Diff for /parser3/src/classes/string.C between versions 1.142 and 1.145

version 1.142, 2005/06/06 08:45:11 version 1.145, 2005/08/26 12:01:38
Line 1 Line 1
 /** @file  /** @file
         Parser: @b string parser class.          Parser: @b string parser class.
   
         Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com)
         Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
 */  */
   
Line 54  static void _length(Request& r, MethodPa Line 54  static void _length(Request& r, MethodPa
 static void _int(Request& r, MethodParams& params) {  static void _int(Request& r, MethodParams& params) {
         const String& self_string=GET_SELF(r, VString).string();          const String& self_string=GET_SELF(r, VString).string();
         int converted;          int converted;
         Value* default_code=params.count()>0?&params.as_junction(0, "default must be int")  
                 :0; // (default)  
         try {          try {
                 if(self_string.is_empty())                  if(self_string.is_empty())
                         throw Exception("parser.runtime",                          throw Exception("parser.runtime",
Line 63  static void _int(Request& r, MethodParam Line 61  static void _int(Request& r, MethodParam
                                 "parameter is empty string, error converting");                                  "parameter is empty string, error converting");
                 converted=self_string.as_int();                  converted=self_string.as_int();
         } catch(...) { // convert problem          } catch(...) { // convert problem
                 if(default_code)                  if(params.count()>0)
                         converted=r.process_to_value(*default_code).as_int();                          converted=params.as_int(0, "default must be int", r); // (default)
                 else                  else
                         rethrow; // we have a problem when no default                                             rethrow; // we have a problem when no default                   
         }          }
Line 74  static void _int(Request& r, MethodParam Line 72  static void _int(Request& r, MethodParam
 static void _double(Request& r, MethodParams& params) {  static void _double(Request& r, MethodParams& params) {
         const String& self_string=GET_SELF(r, VString).string();          const String& self_string=GET_SELF(r, VString).string();
         double converted;          double converted;
         Value* default_code=params.count()>0?&params.as_junction(0, "default must be double")  
                 :0; // (default)  
         try {          try {
                 if(self_string.is_empty())                  if(self_string.is_empty())
                         throw Exception("parser.runtime",                          throw Exception("parser.runtime",
Line 83  static void _double(Request& r, MethodPa Line 79  static void _double(Request& r, MethodPa
                                 "parameter is empty string, error converting");                                  "parameter is empty string, error converting");
                 converted=self_string.as_double();                  converted=self_string.as_double();
         } catch(...) { // convert problem          } catch(...) { // convert problem
                 if(default_code)                  if(params.count()>0)
                         converted=r.process_to_value(*default_code).as_double();                          converted=params.as_double(0, "default must be double", r); // (default)
                 else                  else
                         rethrow; // we have a problem when no default                          rethrow; // we have a problem when no default
         }          }
Line 433  const String* sql_result_string(Request& Line 429  const String* sql_result_string(Request&
         default_code=0;          default_code=0;
         if(params.count()>1) {          if(params.count()>1) {
                 Value& voptions=params.as_no_junction(1, "options must be hash, not code");                  Value& voptions=params.as_no_junction(1, "options must be hash, not code");
                 if(!voptions.is_string())                  if(voptions.is_defined() && !voptions.is_string())
                         if((options=voptions.get_hash())) {                          if((options=voptions.get_hash())) {
                                 int valid_options=0;                                  int valid_options=0;
                                 if(Value* vbind=options->get(sql_bind_name)) {                                  if(Value* vbind=options->get(sql_bind_name)) {

Removed from v.1.142  
changed lines
  Added in v.1.145


E-mail: