/usr/include/Poco/Data/LOB.h is in libpoco-dev 1.8.0.1-1ubuntu4.
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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | //
// LOB.h
//
// Library: Data
// Package: DataCore
// Module: LOB
//
// Definition of the LOB class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Data_LOB_INCLUDED
#define Data_LOB_INCLUDED
#include "Poco/Data/Data.h"
#include "Poco/SharedPtr.h"
#include "Poco/Dynamic/VarHolder.h"
#include "Poco/Exception.h"
#include <vector>
#include <algorithm>
namespace Poco {
namespace Data {
template <typename T>
class LOB
/// Representation of a Large OBject.
///
/// A LOB can hold arbitrary data.
/// The maximum size depends on the underlying database.
///
/// The LOBInputStream and LOBOutputStream classes provide
/// a convenient way to access the data in a LOB.
{
public:
typedef typename std::vector<T>::const_iterator Iterator;
typedef T ValueType;
typedef typename std::vector<T> Container;
typedef Poco::SharedPtr<Container> ContentPtr;
LOB(): _pContent(new std::vector<T>())
/// Creates an empty LOB.
{
}
LOB(const std::vector<T>& content):
_pContent(new std::vector<T>(content))
/// Creates the LOB, content is deep-copied.
{
}
LOB(const T* const pContent, std::size_t size):
_pContent(new std::vector<T>(pContent, pContent + size))
/// Creates the LOB by deep-copying pContent.
{
}
LOB(const std::basic_string<T>& content):
_pContent(new std::vector<T>(content.begin(), content.end()))
/// Creates a LOB from a string.
{
}
LOB(const LOB& other): _pContent(other._pContent)
/// Creates a LOB by copying another one.
{
}
~LOB()
/// Destroys the LOB.
{
}
LOB& operator = (const LOB& other)
/// Assignment operator.
{
LOB tmp(other);
swap(tmp);
return *this;
}
bool operator == (const LOB& other) const
/// Compares for equality LOB by value.
{
return *_pContent == *other._pContent;
}
bool operator != (const LOB& other) const
/// Compares for inequality LOB by value.
{
return *_pContent != *other._pContent;
}
void swap(LOB& other)
/// Swaps the LOB with another one.
{
using std::swap;
swap(_pContent, other._pContent);
}
const std::vector<T>& content() const
/// Returns the content.
{
return *_pContent;
}
const T* rawContent() const
/// Returns the raw content.
///
/// If the LOB is empty, returns NULL.
{
if (_pContent->empty())
return 0;
else
return &(*_pContent)[0];
}
void assignVal(std::size_t count, const T& val)
/// Assigns raw content to internal storage.
{
ContentPtr tmp = new Container(count, val);
_pContent.swap(tmp);
}
void assignRaw(const T* ptr, std::size_t count)
/// Assigns raw content to internal storage.
{
poco_assert_dbg (ptr);
LOB tmp(ptr, count);
swap(tmp);
}
void appendRaw(const T* pChar, std::size_t count)
/// Assigns raw content to internal storage.
{
poco_assert_dbg (pChar);
_pContent->insert(_pContent->end(), pChar, pChar+count);
}
void clear(bool doCompact = false)
/// Clears the content of the blob.
/// If doCompact is true, trims the excess capacity.
{
_pContent->clear();
if (doCompact) compact();
}
void compact()
/// Trims the internal storage excess capacity.
{
std::vector<T>(*_pContent).swap(*_pContent);
}
Iterator begin() const
{
return _pContent->begin();
}
Iterator end() const
{
return _pContent->end();
}
std::size_t size() const
/// Returns the size of the LOB in bytes.
{
return static_cast<std::size_t>(_pContent->size());
}
private:
ContentPtr _pContent;
};
typedef LOB<unsigned char> BLOB;
typedef LOB<char> CLOB;
//
// inlines
//
template <typename T>
inline void swap(LOB<T>& b1, LOB<T>& b2)
{
b1.swap(b2);
}
} } // namespace Poco::Data
namespace std
{
template<>
inline void swap<Poco::Data::BLOB>(Poco::Data::BLOB& b1,
Poco::Data::BLOB& b2)
/// Full template specalization of std:::swap for BLOB
{
b1.swap(b2);
}
template<>
inline void swap<Poco::Data::CLOB>(Poco::Data::CLOB& c1,
Poco::Data::CLOB& c2)
/// Full template specalization of std:::swap for CLOB
{
c1.swap(c2);
}
}
//
// VarHolderImpl<LOB>
//
namespace Poco {
namespace Dynamic {
template <>
class VarHolderImpl<Poco::Data::BLOB>: public VarHolder
{
public:
VarHolderImpl(const Poco::Data::BLOB& val): _val(val)
{
}
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(Poco::Data::BLOB);
}
void convert(std::string& val) const
{
val.assign(_val.begin(), _val.end());
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
{
return cloneHolder(pVarHolder, _val);
}
const Poco::Data::BLOB& value() const
{
return _val;
}
private:
VarHolderImpl();
Poco::Data::BLOB _val;
};
template <>
class VarHolderImpl<Poco::Data::CLOB>: public VarHolder
{
public:
VarHolderImpl(const Poco::Data::CLOB& val): _val(val)
{
}
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(Poco::Data::CLOB);
}
void convert(std::string& val) const
{
val.assign(_val.begin(), _val.end());
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
{
return cloneHolder(pVarHolder, _val);
}
const Poco::Data::CLOB& value() const
{
return _val;
}
private:
VarHolderImpl();
Poco::Data::CLOB _val;
};
} } // namespace Poco::Dynamic
#endif // Data_LOB_INCLUDED
|