Warning, file /sdk/codevis/thirdparty/soci/include/private/soci-vector-helpers.h 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) 2021 Sinitsyn Ilya
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 #ifndef SOCI_VECTOR_HELPERS_H_INCLUDED
0009 #define SOCI_VECTOR_HELPERS_H_INCLUDED
0010 
0011 #include "soci-exchange-cast.h"
0012 
0013 namespace soci
0014 {
0015 
0016 namespace details
0017 {
0018 
0019 // Helper functions to work with vectors.
0020 
0021 template <exchange_type e>
0022 std::vector<typename exchange_type_traits<e>::value_type>& exchange_vector_type_cast(void *data)
0023 {
0024     return *static_cast<std::vector<typename exchange_type_traits<e>::value_type>*>(data);
0025 }
0026 
0027 // Get the size of the vector.
0028 inline std::size_t get_vector_size(exchange_type e, void *data)
0029 {
0030     switch (e)
0031     {
0032         case x_char:
0033             return exchange_vector_type_cast<x_char>(data).size();
0034         case x_stdstring:
0035             return exchange_vector_type_cast<x_stdstring>(data).size();
0036         case x_short:
0037             return exchange_vector_type_cast<x_short>(data).size();
0038         case x_integer:
0039             return exchange_vector_type_cast<x_integer>(data).size();
0040         case x_long_long:
0041             return exchange_vector_type_cast<x_long_long>(data).size();
0042         case x_unsigned_long_long:
0043             return exchange_vector_type_cast<x_unsigned_long_long>(data).size();
0044         case x_double:
0045             return exchange_vector_type_cast<x_double>(data).size();
0046         case x_stdtm:
0047             return exchange_vector_type_cast<x_stdtm>(data).size();
0048         case x_xmltype:
0049             return exchange_vector_type_cast<x_xmltype>(data).size();
0050         case x_longstring:
0051             return exchange_vector_type_cast<x_longstring>(data).size();
0052         case x_statement:
0053         case x_rowid:
0054         case x_blob:
0055             break;
0056     }
0057     throw soci_error("Failed to get the size of the vector of non-supported type.");
0058 }
0059 
0060 // Set the size of the vector.
0061 inline void resize_vector(exchange_type e, void *data, std::size_t newSize)
0062 {
0063     switch (e)
0064     {
0065         case x_char:
0066             exchange_vector_type_cast<x_char>(data).resize(newSize);
0067             return;
0068         case x_stdstring:
0069             exchange_vector_type_cast<x_stdstring>(data).resize(newSize);
0070             return;
0071         case x_short:
0072             exchange_vector_type_cast<x_short>(data).resize(newSize);
0073             return;
0074         case x_integer:
0075             exchange_vector_type_cast<x_integer>(data).resize(newSize);
0076             return;
0077         case x_long_long:
0078             exchange_vector_type_cast<x_long_long>(data).resize(newSize);
0079             return;
0080         case x_unsigned_long_long:
0081             exchange_vector_type_cast<x_unsigned_long_long>(data).resize(newSize);
0082             return;
0083         case x_double:
0084             exchange_vector_type_cast<x_double>(data).resize(newSize);
0085             return;
0086         case x_stdtm:
0087             exchange_vector_type_cast<x_stdtm>(data).resize(newSize);
0088             return;
0089         case x_xmltype:
0090             exchange_vector_type_cast<x_xmltype>(data).resize(newSize);
0091             return;
0092         case x_longstring:
0093             exchange_vector_type_cast<x_longstring>(data).resize(newSize);
0094             return;
0095         case x_statement:
0096         case x_rowid:
0097         case x_blob:
0098             break;
0099     }
0100     throw soci_error("Failed to get the size of the vector of non-supported type.");
0101 }
0102 
0103 // Get the string at the given index of the vector.
0104 inline std::string& vector_string_value(exchange_type e, void *data, std::size_t ind)
0105 {
0106     switch (e)
0107     {
0108         case x_stdstring:
0109             return exchange_vector_type_cast<x_stdstring>(data).at(ind);
0110         case x_xmltype:
0111             return exchange_vector_type_cast<x_xmltype>(data).at(ind).value;
0112         case x_longstring:
0113             return exchange_vector_type_cast<x_longstring>(data).at(ind).value;
0114         case x_char:
0115         case x_short:
0116         case x_integer:
0117         case x_long_long:
0118         case x_unsigned_long_long:
0119         case x_double:
0120         case x_stdtm:
0121         case x_statement:
0122         case x_rowid:
0123         case x_blob:
0124             break;
0125     }
0126     throw soci_error("Can't get the string value from the vector of values with non-supported type.");
0127 }
0128 
0129 } // namespace details
0130 
0131 } // namespace soci
0132 
0133 #endif // SOCI_VECTOR_HELPERS_H_INCLUDED