Warning, file /sdk/codevis/thirdparty/soci/src/core/row.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // 0002 // Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton 0003 // Distributed under the Boost Software License, Version 1.0. 0004 // (See accompanying file LICENSE_1_0.txt or copy at 0005 // http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 0008 #define SOCI_SOURCE 0009 #include "soci/row.h" 0010 0011 #include <cstddef> 0012 #include <cctype> 0013 #include <sstream> 0014 #include <string> 0015 0016 using namespace soci; 0017 using namespace details; 0018 0019 row::row() 0020 : uppercaseColumnNames_(false) 0021 , currentPos_(0) 0022 {} 0023 0024 row::~row() 0025 { 0026 clean_up(); 0027 } 0028 0029 void row::uppercase_column_names(bool forceToUpper) 0030 { 0031 uppercaseColumnNames_ = forceToUpper; 0032 } 0033 0034 void row::add_properties(column_properties const &cp) 0035 { 0036 columns_.push_back(cp); 0037 0038 std::string columnName; 0039 std::string const & originalName = cp.get_name(); 0040 if (uppercaseColumnNames_) 0041 { 0042 for (std::size_t i = 0; i != originalName.size(); ++i) 0043 { 0044 columnName.push_back(static_cast<char>(std::toupper(originalName[i]))); 0045 } 0046 0047 // rewrite the column name in the column_properties object 0048 // as well to retain consistent views 0049 0050 columns_[columns_.size() - 1].set_name(columnName); 0051 } 0052 else 0053 { 0054 columnName = originalName; 0055 } 0056 0057 index_[columnName] = columns_.size() - 1; 0058 } 0059 0060 std::size_t row::size() const 0061 { 0062 return holders_.size(); 0063 } 0064 0065 void row::clean_up() 0066 { 0067 std::size_t const hsize = holders_.size(); 0068 for (std::size_t i = 0; i != hsize; ++i) 0069 { 0070 delete holders_[i]; 0071 delete indicators_[i]; 0072 } 0073 0074 columns_.clear(); 0075 holders_.clear(); 0076 indicators_.clear(); 0077 index_.clear(); 0078 } 0079 0080 indicator row::get_indicator(std::size_t pos) const 0081 { 0082 return *indicators_.at(pos); 0083 } 0084 0085 indicator row::get_indicator(std::string const &name) const 0086 { 0087 return get_indicator(find_column(name)); 0088 } 0089 0090 column_properties const & row::get_properties(std::size_t pos) const 0091 { 0092 return columns_.at(pos); 0093 } 0094 0095 column_properties const & row::get_properties(std::string const &name) const 0096 { 0097 return get_properties(find_column(name)); 0098 } 0099 0100 std::size_t row::find_column(std::string const &name) const 0101 { 0102 std::map<std::string, std::size_t>::const_iterator it = index_.find(name); 0103 if (it == index_.end()) 0104 { 0105 std::ostringstream msg; 0106 msg << "Column '" << name << "' not found"; 0107 throw soci_error(msg.str()); 0108 } 0109 0110 return it->second; 0111 }