Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes

MySqlPL::SqlResult Struct Reference

#include <mysqlpl.h>

Inheritance diagram for MySqlPL::SqlResult:
Inheritance graph
[legend]
Collaboration diagram for MySqlPL::SqlResult:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SqlResult (SqlStatement &stmt)
bool is_null (int idx) const
int is_null (const std::string &col_name) const
bool is_not_null (int idx) const
int is_not_null (const std::string &col_name) const
int get_int (int idx) const
int get_int (const std::string &col_name) const
double get_double (int idx) const
double get_double (const std::string &col_name) const
std::string get_string (int idx) const
std::string get_string (const std::string &col_name) const
int get_column_count () const
const ColumnTypeget_column_type (int idx) const
const ColumnTypeget_column_type (const std::string &col_name) const
void print_columns (std::ostream &out)
void print_values (std::ostream &out)

Public Attributes

MYSQL_ROW _row

Protected Types

typedef std::map< std::string,
int > 
NameMap

Protected Member Functions

NameMap::const_iterator find_column (const std::string &col_name) const
int get_column_idx (const std::string &col_name) const

Protected Attributes

SqlStatement_stmt
ColumnVector _columns
NameMap _name_map

Detailed Description

Definition at line 1087 of file mysqlpl.h.


Member Typedef Documentation

typedef std::map<std::string, int> MySqlPL::SqlRecord::NameMap [protected, inherited]

Definition at line 1077 of file mysqlpl.h.


Constructor & Destructor Documentation

MySqlPL::SqlResult::SqlResult ( SqlStatement stmt ) [inline]

Definition at line 1091 of file mysqlpl.h.

     :  SqlRecord(stmt),
        _row(NULL)
    {
    }

Member Function Documentation

SqlRecord::NameMap::const_iterator MySqlPL::SqlRecord::find_column ( const std::string &  col_name ) const [protected, inherited]

Definition at line 908 of file mysqlpl.cpp.

References MySqlPL::SqlRecord::_columns, MySqlPL::SqlRecord::_name_map, and _strupr_s.

Referenced by MySqlPL::SqlRecord::get_column_idx(), and MySqlPL::SqlRecord::get_column_type().

{
    std::string upper_name;

     // initialize column name map
    if (_name_map.empty()) {
        int idx = 0;

        for(ColumnVector::const_iterator it=_columns.begin(); it!=_columns.end(); ++it,++idx) {
            upper_name = it->_type._name.c_str();
            _strupr_s((char*)upper_name.data(), upper_name.length()+1);

            _name_map[upper_name] = idx;
        }
    }

    upper_name = col_name;
    _strupr_s((char*)upper_name.data(), upper_name.length()+1);

    return _name_map.find(upper_name);
}

Here is the caller graph for this function:

int MySqlPL::SqlRecord::get_column_count (  ) const [inline, inherited]

Definition at line 1051 of file mysqlpl.h.

References MySqlPL::SqlRecord::_columns.

        {return _columns.size();}
int MySqlPL::SqlRecord::get_column_idx ( const std::string &  col_name ) const [protected, inherited]

Definition at line 930 of file mysqlpl.cpp.

References MySqlPL::SqlRecord::_name_map, MySqlPL::SqlRecord::find_column(), and THROW_MYSQLPL_EXCEPTION.

Referenced by get_double(), get_int(), get_string(), is_not_null(), and is_null().

{
    NameMap::const_iterator found = find_column(col_name);

    if (found != _name_map.end())
        return found->second;
    else {
        THROW_MYSQLPL_EXCEPTION("column not found");
        return -1;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

const ColumnType& MySqlPL::SqlRecord::get_column_type ( int  idx ) const [inline, inherited]

Definition at line 1061 of file mysqlpl.h.

References MySqlPL::SqlRecord::_columns.

        {return _columns[idx]._type;}
const ColumnType & MySqlPL::SqlRecord::get_column_type ( const std::string &  col_name ) const [inherited]

Definition at line 880 of file mysqlpl.cpp.

References MySqlPL::SqlRecord::_columns, MySqlPL::SqlRecord::_name_map, MySqlPL::SqlRecord::find_column(), and THROW_MYSQLPL_EXCEPTION.

{
    NameMap::const_iterator found = find_column(col_name);

    if (found != _name_map.end()) {
        int idx = found->second;
        return _columns[idx]._type;
    } else {
        THROW_MYSQLPL_EXCEPTION("column not found");
        return *(ColumnType*)NULL;
    }
}

Here is the call graph for this function:

double MySqlPL::SqlResult::get_double ( int  idx ) const [inline]

Definition at line 1135 of file mysqlpl.h.

References _row.

Referenced by get_double().

    {
        return atof(_row[idx]);
    }

Here is the caller graph for this function:

double MySqlPL::SqlResult::get_double ( const std::string &  col_name ) const [inline]

Definition at line 1139 of file mysqlpl.h.

References MySqlPL::SqlRecord::get_column_idx(), and get_double().

    {
        return get_double(get_column_idx(col_name));
    }

Here is the call graph for this function:

int MySqlPL::SqlResult::get_int ( int  idx ) const [inline]

Definition at line 1115 of file mysqlpl.h.

References _row.

Referenced by get_int().

    {
        return atoi(_row[idx]);
    }

Here is the caller graph for this function:

int MySqlPL::SqlResult::get_int ( const std::string &  col_name ) const [inline]

Definition at line 1119 of file mysqlpl.h.

References MySqlPL::SqlRecord::get_column_idx(), and get_int().

    {
        return get_int(get_column_idx(col_name));
    }

Here is the call graph for this function:

std::string MySqlPL::SqlResult::get_string ( int  idx ) const [inline]

Definition at line 1144 of file mysqlpl.h.

References _row.

Referenced by get_string().

    {
        const char* str = _row[idx];
        return str? str: std::string();
    }

Here is the caller graph for this function:

std::string MySqlPL::SqlResult::get_string ( const std::string &  col_name ) const [inline]

Definition at line 1149 of file mysqlpl.h.

References MySqlPL::SqlRecord::get_column_idx(), and get_string().

    {
        return get_string(get_column_idx(col_name));
    }

Here is the call graph for this function:

bool MySqlPL::SqlResult::is_not_null ( int  idx ) const [inline]

Definition at line 1106 of file mysqlpl.h.

References _row.

Referenced by is_not_null().

    {
        return _row[idx] != NULL;
    }

Here is the caller graph for this function:

int MySqlPL::SqlResult::is_not_null ( const std::string &  col_name ) const [inline]

Definition at line 1110 of file mysqlpl.h.

References MySqlPL::SqlRecord::get_column_idx(), and is_not_null().

    {
        return is_not_null(get_column_idx(col_name));
    }

Here is the call graph for this function:

int MySqlPL::SqlResult::is_null ( const std::string &  col_name ) const [inline]

Definition at line 1101 of file mysqlpl.h.

References MySqlPL::SqlRecord::get_column_idx(), and is_null().

    {
        return is_null(get_column_idx(col_name));
    }

Here is the call graph for this function:

bool MySqlPL::SqlResult::is_null ( int  idx ) const [inline]

Definition at line 1097 of file mysqlpl.h.

References _row.

Referenced by is_null().

    {
        return _row[idx] == NULL;
    }

Here is the caller graph for this function:

void MySqlPL::SqlRecord::print_columns ( std::ostream &  out ) [inherited]

Definition at line 943 of file mysqlpl.cpp.

References MySqlPL::ColumnType::_name, MySqlPL::ColumnType::_table_name, and MySqlPL::ColumnType::get_type_str().

Referenced by MySqlPL::SqlStatement::print_results().

{
    for(ColumnVector::const_iterator it=_columns.begin(); it!=_columns.end(); ++it) {
        const ColumnType& type = it->_type;

        if (!type._table_name.empty())
            out << type._table_name << ".";

        out << type._name << ": " << type.get_type_str() << std::endl;
    }

    out << std::endl;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MySqlPL::SqlRecord::print_values ( std::ostream &  out ) [inherited]

Definition at line 957 of file mysqlpl.cpp.

References MySqlPL::ColumnType::_name.

Referenced by MySqlPL::SqlStatement::print_results().

{
#if MYSQLPL_PREP_STMT
    for(ColumnVector::const_iterator it=_columns.begin(); it!=_columns.end(); ++it) {
        const ColumnType& type = it->_type;

//      if (!type._table_name.empty())
//          out << type._table_name << ".";

        out << type._name << "=" << it->_column.str() << std::endl;
    }
#else
    for(size_t i=0; i<_columns.size(); ++i) {
        const ColumnType& type = _columns[i]._type;

//      if (!type._table_name.empty())
//          out << type._table_name << ".";

        out << type._name << "=" << _stmt->get_string(i) << std::endl;
    }
#endif
}

Here is the caller graph for this function:


Member Data Documentation

NameMap MySqlPL::SqlRecord::_name_map [mutable, protected, inherited]
SqlStatement& MySqlPL::SqlRecord::_stmt [protected, inherited]

Definition at line 1074 of file mysqlpl.h.


The documentation for this struct was generated from the following file: