|
|
| version 1.349, 2019/11/23 23:48:41 | version 1.355, 2020/12/17 19:51:21 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b table parser class. | Parser: @b table parser class. |
| Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| #include "pa_config_includes.h" | |
| #if (!defined(NO_STRINGSTREAM) && !defined(FREEBSD4) && !defined(PA_DEBUG_DISABLE_GC)) | |
| #include <sstream> | |
| #include "../lib/gc/include/gc_allocator.h" | |
| #define USE_STRINGSTREAM | |
| #endif | |
| #include "classes.h" | #include "classes.h" |
| #include "pa_vmethod_frame.h" | #include "pa_vmethod_frame.h" |
| Line 17 | Line 25 |
| #include "pa_vbool.h" | #include "pa_vbool.h" |
| #include "pa_array.h" | #include "pa_array.h" |
| #if (!defined(NO_STRINGSTREAM) && !defined(FREEBSD4) && !defined(PA_DEBUG_DISABLE_GC)) | |
| #include <sstream> | |
| #define USE_STRINGSTREAM | |
| #endif | |
| volatile const char * IDENT_TABLE_C="$Id$"; | volatile const char * IDENT_TABLE_C="$Id$"; |
| // class | // class |
| Line 410 static void _load(Request& r, MethodPara | Line 413 static void _load(Request& r, MethodPara |
| control_chars.load(*options); | control_chars.load(*options); |
| // loading text | // loading text |
| char *data=file_load_text(r, r.absolute(params.as_string(filename_param_index, FILE_NAME_MUST_BE_STRING)), true, options); | char *data=file_load_text(r, r.full_disk_path(params.as_string(filename_param_index, FILE_NAME_MUST_BE_STRING)), true, options); |
| Skip_lines_action skip_lines_action = (control_chars.separator=='#' || control_chars.encloser=='#') ? skip_empty_lines : skip_empty_and_comment_lines; | Skip_lines_action skip_lines_action = (control_chars.separator=='#' || control_chars.encloser=='#') ? skip_empty_lines : skip_empty_and_comment_lines; |
| Line 454 static void _load(Request& r, MethodPara | Line 457 static void _load(Request& r, MethodPara |
| } | } |
| #ifdef USE_STRINGSTREAM | #ifdef USE_STRINGSTREAM |
| #include "../lib/gc/include/gc_allocator.h" | |
| typedef std::basic_stringstream<char, std::char_traits<char>, gc_allocator<char> > pa_stringstream; | typedef std::basic_stringstream<char, std::char_traits<char>, gc_allocator<char> > pa_stringstream; |
| typedef std::basic_string<char, std::char_traits<char>, gc_allocator<char> > pa_string; | typedef std::basic_string<char, std::char_traits<char>, gc_allocator<char> > pa_string; |
| Line 633 static void _save(Request& r, MethodPara | Line 635 static void _save(Request& r, MethodPara |
| --param_index; | --param_index; |
| const String& file_name=params.as_string(param_index++, FILE_NAME_MUST_NOT_BE_CODE); | const String& file_name=params.as_string(param_index++, FILE_NAME_MUST_NOT_BE_CODE); |
| String file_spec=r.absolute(file_name); | String file_spec=r.full_disk_path(file_name); |
| if(do_append && file_exist(file_spec)) | if(do_append && file_exist(file_spec)) |
| output_column_names=false; | output_column_names=false; |
| Line 1257 static void join_nameless_row(Table& src | Line 1259 static void join_nameless_row(Table& src |
| *dest+=src[src.current()]; | *dest+=src[src.current()]; |
| } | } |
| static void _join(Request& r, MethodParams& params) { | static void _join(Request& r, MethodParams& params) { |
| Table& src=*params.as_table(0, "source"); | if(Table* src=params.as_table(0, "source")){ |
| Table::Action_options o=get_action_options(r, params, 1, *src); | |
| Table::Action_options o=get_action_options(r, params, 1, src); | |
| Table& dest=GET_SELF(r, VTable).table(); | Table& dest=GET_SELF(r, VTable).table(); |
| if(&src == &dest) | if(src == &dest) |
| throw Exception(PARSER_RUNTIME, 0, "source and destination are same table"); | throw Exception(PARSER_RUNTIME, 0, "source and destination are same table"); |
| if(dest.columns()) // dest is named | if(dest.columns()) // dest is named |
| src.table_for_each(join_named_row, &dest, o); | src->table_for_each(join_named_row, &dest, o); |
| else // dest is nameless | else // dest is nameless |
| src.table_for_each(join_nameless_row, &dest, o); | src->table_for_each(join_nameless_row, &dest, o); |
| } | |
| } | } |
| #ifndef DOXYGEN | #ifndef DOXYGEN |