/usr/include/soci/row.h is in libsoci-dev 3.2.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | //
// Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef SOCI_ROW_H_INCLUDED
#define SOCI_ROW_H_INCLUDED
#include "type-holder.h"
#include "soci-backend.h"
#include "type-conversion.h"
// std
#include <cassert>
#include <cstddef>
#include <map>
#include <string>
#include <vector>
namespace soci
{
class SOCI_DECL column_properties
{
// use getters/setters in case we want to make some
// of the getters lazy in the future
public:
std::string get_name() const { return name_; }
data_type get_data_type() const { return dataType_; }
void set_name(std::string const& name) { name_ = name; }
void set_data_type(data_type dataType) { dataType_ = dataType; }
private:
std::string name_;
data_type dataType_;
};
class SOCI_DECL row
{
public:
row();
~row();
void uppercase_column_names(bool forceToUpper);
void add_properties(column_properties const& cp);
std::size_t size() const;
void clean_up();
indicator get_indicator(std::size_t pos) const;
indicator get_indicator(std::string const& name) const;
template <typename T>
inline void add_holder(T* t, indicator* ind)
{
holders_.push_back(new details::type_holder<T>(t));
indicators_.push_back(ind);
}
column_properties const& get_properties(std::size_t pos) const;
column_properties const& get_properties(std::string const& name) const;
template <typename T>
T get(std::size_t pos) const
{
assert(holders_.size() >= pos + 1);
typedef typename type_conversion<T>::base_type base_type;
base_type const& baseVal = holders_[pos]->get<base_type>();
T ret;
type_conversion<T>::from_base(baseVal, *indicators_[pos], ret);
return ret;
}
template <typename T>
T get(std::size_t pos, T const &nullValue) const
{
assert(holders_.size() >= pos + 1);
if (i_null == *indicators_[pos])
{
return nullValue;
}
return get<T>(pos);
}
template <typename T>
T get(std::string const &name) const
{
std::size_t const pos = find_column(name);
return get<T>(pos);
}
template <typename T>
T get(std::string const &name, T const &nullValue) const
{
std::size_t const pos = find_column(name);
if (i_null == *indicators_[pos])
{
return nullValue;
}
return get<T>(pos);
}
template <typename T>
row const& operator>>(T& value) const
{
value = get<T>(currentPos_);
++currentPos_;
return *this;
}
void skip(std::size_t num = 1) const
{
currentPos_ += num;
}
void reset_get_counter() const
{
currentPos_ = 0;
}
private:
// copy not supported
row(row const &);
void operator=(row const &);
std::size_t find_column(std::string const& name) const;
std::vector<column_properties> columns_;
std::vector<details::holder*> holders_;
std::vector<indicator*> indicators_;
std::map<std::string, std::size_t> index_;
bool uppercaseColumnNames_;
mutable std::size_t currentPos_;
};
} // namespace soci
#endif // SOCI_ROW_H_INCLUDED
|