Diff for /parser3/src/classes/table.C between versions 1.239 and 1.241

version 1.239, 2008/02/14 09:10:24 version 1.241, 2008/04/08 12:34:01
Line 7 Line 7
   
 static const char * const IDENT_TABLE_C="$Date$";  static const char * const IDENT_TABLE_C="$Date$";
   
   #ifndef NO_STRINGSTREAM
 #include <sstream>  #include <sstream>
 using namespace std;  using namespace std;
   #endif
   
 #include "classes.h"  #include "classes.h"
 #include "pa_vmethod_frame.h"  #include "pa_vmethod_frame.h"
Line 387  static void _load(Request& r, MethodPara Line 389  static void _load(Request& r, MethodPara
         GET_SELF(r, VTable).set_table(table);          GET_SELF(r, VTable).set_table(table);
 }  }
   
   #ifdef NO_STRINGSTREAM
   
 void maybe_enclose( String& to, const String& from, char encloser, const String* sencloser ) {  void maybe_enclose( String& to, const String& from, char encloser, const String* sencloser ) {
         if(encloser) {          if(encloser) {
                 to<<*sencloser;                  to<<*sencloser;
Line 407  void maybe_enclose( String& to, const St Line 411  void maybe_enclose( String& to, const St
                 to<<from;                  to<<from;
 }  }
   
   #else
   
 void maybe_enclose( ostringstream& to, const String& from, char encloser ) {  void maybe_enclose( ostringstream& to, const String& from, char encloser ) {
         if(encloser) {          if(encloser) {
                 to<<encloser;                  to<<encloser;
Line 427  void maybe_enclose( ostringstream& to, c Line 433  void maybe_enclose( ostringstream& to, c
                 to<<from.cstr();                  to<<from.cstr();
 }  }
   
 /*  #endif
 static void _save_old(Request& r, MethodParams& params) {  
   static void _save(Request& r, MethodParams& params) {
         const String& first_arg=params.as_string(0, FIRST_ARG_MUST_NOT_BE_CODE);          const String& first_arg=params.as_string(0, FIRST_ARG_MUST_NOT_BE_CODE);
         size_t param_index=1;          size_t param_index=1;
   
Line 469  static void _save_old(Request& r, Method Line 476  static void _save_old(Request& r, Method
   
         Table& table=GET_SELF(r, VTable).table();          Table& table=GET_SELF(r, VTable).table();
   
   #ifdef NO_STRINGSTREAM
   
         String sdata;          String sdata;
         if(output_column_names) {          if(output_column_names) {
                 if(table.columns()) { // named table                  if(table.columns()) { // named table
Line 511  static void _save_old(Request& r, Method Line 520  static void _save_old(Request& r, Method
                 if(*data_cstr) // not empty (when empty it's not heap memory)                  if(*data_cstr) // not empty (when empty it's not heap memory)
                         pa_free((void*)data_cstr); // not needed anymore                          pa_free((void*)data_cstr); // not needed anymore
         }          }
 }  
 */  
   
 static void _save(Request& r, MethodParams& params) {  
         const String& first_arg=params.as_string(0, FIRST_ARG_MUST_NOT_BE_CODE);  
         size_t param_index=1;  
   
         bool do_append=false;  
         bool output_column_names=true;  
   
         // mode?  
         if(first_arg=="append")  
                 do_append=true;  
         else if(first_arg=="nameless")  
                 output_column_names=false;  
         else  
                 --param_index;  
   
         const String& file_name=params.as_string(param_index++, FILE_NAME_MUST_NOT_BE_CODE);  
   
         TableSeparators separators;  
         if(param_index<params.count()) {  
                 Value& voptions=params.as_no_junction(param_index++, "additional params must be hash");  
                 if( voptions.is_defined() && !voptions.is_string() ) {  
                         if(HashStringValue* options=voptions.get_hash()) {  
                                 int valid_options=separators.load(*options);  
                                 if(valid_options!=options->count())  
                                         throw Exception(PARSER_RUNTIME,  
                                                 0,  
                                                 "invalid option passed");  
                         } else {  
                                 throw Exception(PARSER_RUNTIME,  
                                         0,  
                                         "additional params must be hash (did you spell mode parameter correctly?)");  
                         }  
                 }  
         }  
         if(param_index<params.count())  
                 throw Exception(PARSER_RUNTIME,  
                         0,  
                         "bad mode (must be nameless or append)");  
   
         Table& table=GET_SELF(r, VTable).table();  #else
   
         ostringstream ost(stringstream::out);          ostringstream ost(stringstream::out);
   
Line 602  static void _save(Request& r, MethodPara Line 570  static void _save(Request& r, MethodPara
   
                 file_write(r.absolute(file_name), data_cstr, data.length(), true /* as text */, do_append);                  file_write(r.absolute(file_name), data_cstr, data.length(), true /* as text */, do_append);
         }          }
   
   #endif
 }  }
   
 static void _count(Request& r, MethodParams&) {  static void _count(Request& r, MethodParams&) {

Removed from v.1.239  
changed lines
  Added in v.1.241


E-mail: