Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > by-pkgid > a86327fd014dc28b8b792dc8f310a4d6 > files > 119

libhk_classes5-devel-0.6.2a-3mdk.i586.rpm

<HTML>
<HEAD>
<TITLE>Source: hk_classes/hk_classes/hk_importcsv.h</TITLE>

<META NAME="Generator" CONTENT="KDOC ">
</HEAD>
<BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff">
<TABLE WIDTH="100%" BORDER="0">
<TR>
<TD>
	<TABLE BORDER="0">
		<TR><TD valign="top" align="left" cellspacing="10">
		<h1>Source: hk_classes/hk_classes/hk_importcsv.h</h1>
		</TD>
		<TD valign="top" align="right" colspan="1"></TD></TR>
	</TABLE>
	<HR>
	<TABLE BORDER="0">
		
	</TABLE>
	</TD>
<TD align="right"><TABLE BORDER="0"><TR><TD><small><A HREF="index-long.html">Annotated List</A></small></TD></TR>
<TR><TD><small><A HREF="header-list.html">Files</A></small></TD></TR>
<TR><TD><small><A HREF="all-globals.html">Globals</A></small></TD></TR>
<TR><TD><small><A HREF="hier.html">Hierarchy</A></small></TD></TR>
<TR><TD><small><A HREF="index.html">Index</A></small></TD></TR>
</TABLE></TD></TR></TABLE>
<pre>
// ****************************************************************************
// copyright (c) 2000-2002 Horst Knorr <hk_classes@knoda.org>
// This file is part of the hk_classes library.
// This file may be distributed and/or modified under the terms of the
// GNU Library Public License version 2 as published by the Free Software
// Foundation and appearing in the file COPYING included in the
// packaging of this file.
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// ****************************************************************************
#ifndef HK_IMPORTCSV
#define HK_IMPORTCSV
#include <iostream>
#include <fstream>
#include <hk_class.h>
#include <hk_datasource.h>
#include <hk_dsvisible.h>
#include <vector>
using namespace std;

class hk_column;

typedef class colstruct
{
    public:
        colstruct(void){col=NULL;}
        hk_string colname;
        hk_column* col;
} colstruct;
/**
 *
 *@short imports comma delimited textfiles
 *@version $Revision: 1.2 $
 *@author Horst Knorr (hk_classes@knoda.org)

 */

class hk_importcsv:public hk_dsvisible
{
    public:
        hk_importcsv(void);
        virtual ~hk_importcsv(void);


/**
 *after setting all infos start the import with execut
 *@return true if successful else false
 */
        bool    execute(enum_interaction i=interactive);
/**
 *defines the fielddelimiter and the columndelimiter of the csv-file.
 */
        void    set_filedefinition(const hk_string& textdelimiter="\"",const hk_string& betweenfields=",", const hk_string& rowdelimiter="\n");
/**
 *Name of the CSV-file
 */
        void    set_filename(const hk_string& filename);
/**
 *If the first row in the CSV file contains set this function to true else false
 *Default is true
 */
        void    set_firstrow_contains_fieldnames(bool f=true);
/**
 * If user wants to append data, instead of creating a new table or overwriting
 * an existing table.
 * Default is false.
 */
        void    set_append_rows(bool f=false);
/**
 *If set to true a new table will be created else it will be appended to an existing table
 */
        void    set_create_new_table(bool n=true);
/**
 * Define the equivalent column names in an existing table. Column 1 of the CSV File will be added to
 *the first column of the table.
 */
        void    add_columnname(const hk_string& col);
        void    clear_columnlist(void);
        hk_string textdelimiter(void){return p_textdelimiter;}
        hk_string betweenfield(void) {return p_betweenfields;}
        hk_string rowdelimiter(void) {return p_rowdelimiter;}
        void set_overwrite_table(bool);
        bool overwrite_table(void);

    protected:

        void    set_columns(void);
        void    create_automatic_columns(void);
        bool    initialize_table(enum_interaction);
        virtual bool before_columns_deleted(void);
/**
 * If this function returns false the execution of the import will be cancelled
 */

        virtual bool widget_specific_after_new_row(void);

    private:
        void    reset(void);
        void    create_valuelist( hk_string& row);
        bool        p_create_new_table;
/*
 * 0= hk_string
 * 1= float
 * 2= Integer
 * 3= boolean
 */
        int         interpret_columntype(hk_string&f);
        ifstream*   p_filestream;
        hk_string   p_filename;
        hk_string   p_textdelimiter;
        hk_string   p_rowdelimiter;
        hk_string   p_betweenfields;
        bool        p_firstrow_contains_fieldnames;
        vector<hk_string>  p_valuelist;
        vector<colstruct> p_columnlist;
        bool        p_datamode;
        bool        p_notcancelimport;
        bool        p_overwrite;
        hk_datasource::enum_accessmode p_accessmode;
};
#endif
</pre>
<HR>
	<table>
	<tr><td><small>Generated by: horst on horstnotebook on Wed Sep 24 10:38:50 2003, using kdoc 2.0a54.</small></td></tr>
	</table>
</BODY>
</HTML>