00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 2 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * This program is distributed in the hope that it will be useful, 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 * GNU General Public License for more details. 00011 * 00012 * You should have received a copy of the GNU General Public License 00013 * along with this program; if not, write to the Free Software 00014 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00015 * 00016 * (c)Copyright 2006 Hewlett-Packard Development Company, LP. 00017 * 00018 */ 00019 00020 #ifndef _C_EXTERNALDATACONTROL_ 00021 #define _C_EXTERNALDATACONTROL_ 00022 00023 #include "ProtocolData.hpp" 00024 #include "fstream_t.hpp" 00025 00026 #include <regex.h> 00027 00028 class C_ExternalDataControl { 00029 00030 public: 00031 00032 C_ExternalDataControl() ; 00033 virtual ~C_ExternalDataControl() ; 00034 00035 bool init (char * P_file_name); 00036 T_pValueData get_value (int P_line, int P_field); 00037 00038 T_TypeType& get_field_type(int P_field_id) ; 00039 00040 size_t get_nb_field(); 00041 00042 virtual size_t select_line () = 0 ; 00043 00044 00045 protected: 00046 00047 size_t m_number_line ; 00048 size_t m_allocted_nb_line ; 00049 size_t m_max_size_line ; 00050 size_t m_nb_field ; 00051 00052 fstream_input *m_file ; 00053 char *m_file_name ; 00054 00055 T_TypeType *m_field_type_table ; 00056 00057 regex_t *m_regExpr1, *m_regExpr2, *m_regExpr3, *m_regExpr4 ; 00058 00059 T_pValueData **m_data_table ; 00060 00061 size_t m_line_selected ; 00062 size_t m_line_selected_max ; 00063 00064 bool max_buffer_size () ; 00065 00066 bool analyze () ; // determine the types of fields 00067 int get_line (char *P_line); 00068 char* get_field (char *P_line, size_t *P_size, size_t *P_next); 00069 char* field_filtered(char *P_char, size_t P_size) ; 00070 bool analyze_first_data (char*P_line); 00071 bool analyze_data (char*P_line); 00072 00073 bool create_regexp () ; 00074 void delete_regexp () ; 00075 00076 private: 00077 00078 } ; 00079 00080 #endif // _C_EXTERNALDATACONTROL_