src/PreparedStatement.h
branchv_0
changeset 26 49919a60c747
parent 25 ec793cb3e686
child 27 9441a517fa1f
equal deleted inserted replaced
25:ec793cb3e686 26:49919a60c747
       
     1 /**
       
     2  * Relational pipes
       
     3  * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
       
     4  *
       
     5  * This program is free software: you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation, version 3.
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
       
    16  */
       
    17 #pragma once
       
    18 
       
    19 #include <memory>
       
    20 #include <string>
       
    21 #include <sstream>
       
    22 #include <regex>
       
    23 #include <vector>
       
    24 #include <locale>
       
    25 #include <codecvt>
       
    26 #include <unistd.h>
       
    27 #include <cassert>
       
    28 #include <sys/stat.h>
       
    29 
       
    30 #include <sqlite3.h>
       
    31 
       
    32 #include <relpipe/reader/typedefs.h>
       
    33 #include <relpipe/reader/TypeId.h>
       
    34 #include <relpipe/reader/handlers/RelationalReaderValueHandler.h>
       
    35 #include <relpipe/reader/handlers/AttributeMetadata.h>
       
    36 
       
    37 #include <relpipe/writer/Factory.h>
       
    38 
       
    39 #include "Configuration.h"
       
    40 #include "SqlException.h"
       
    41 
       
    42 namespace relpipe {
       
    43 namespace tr {
       
    44 namespace sql {
       
    45 
       
    46 using namespace std;
       
    47 using namespace relpipe;
       
    48 using namespace relpipe::reader;
       
    49 using namespace relpipe::reader::handlers;
       
    50 
       
    51 class PreparedStatement {
       
    52 private:
       
    53 	sqlite3_stmt* stmt;
       
    54 
       
    55 public:
       
    56 
       
    57 	PreparedStatement(sqlite3_stmt* stmt);
       
    58 
       
    59 	virtual ~PreparedStatement();
       
    60 
       
    61 	void setBoolean(int parameterIndex, relpipe::reader::boolean_t value);
       
    62 
       
    63 	void setInteger(int parameterIndex, relpipe::reader::integer_t value);
       
    64 
       
    65 	void setString(int parameterIndex, std::string value);
       
    66 
       
    67 	void setNull(int parameterIndex);
       
    68 
       
    69 	bool next();
       
    70 
       
    71 	void reset();
       
    72 
       
    73 	int getColumnCount();
       
    74 
       
    75 	std::string getColumName(int columnIndex);
       
    76 
       
    77 	relpipe::writer::TypeId getColumType(int columnIndex, relpipe::writer::TypeId defaultType = relpipe::writer::TypeId::STRING);
       
    78 
       
    79 	std::string getString(int columnIndex);
       
    80 
       
    81 };
       
    82 
       
    83 }
       
    84 }
       
    85 }