rpm: removed .la files, and fixed library packaging
[barry/progweb.git] / src / builder.cc
blobb49981d78046c46a5a7e51b010ced703c8495d89
1 ///
2 /// \file builder.cc
3 /// Virtual protocol packet builder wrapper
4 ///
6 /*
7 Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include "builder.h"
23 #include <stdexcept>
24 #include <string.h>
26 namespace Barry {
28 //////////////////////////////////////////////////////////////////////////////
29 // DBDataBuilder class
32 DBDataBuilder::DBDataBuilder(const DBData &orig)
33 : m_orig(orig)
37 DBDataBuilder::~DBDataBuilder()
41 bool DBDataBuilder::BuildRecord(DBData &data, size_t &offset,
42 const IConverter *ic)
44 if( offset == m_orig.GetOffset() ) {
45 data = m_orig;
47 else {
48 // copy the metadata
49 data.CopyMeta(m_orig);
51 // copy the buffer, to the new offset
52 if( m_orig.GetOffset() > m_orig.GetData().GetSize() )
53 throw std::logic_error("DBDataBuilder: offset greater than size");
54 size_t actual = m_orig.GetData().GetSize() - m_orig.GetOffset();
55 size_t total = offset + actual;
56 unsigned char *buf = data.UseData().GetBuffer(total);
57 memcpy(buf + offset,
58 m_orig.GetData().GetData() + m_orig.GetOffset(),
59 actual);
60 data.UseData().ReleaseBuffer(total);
62 // set the new offset
63 data.SetOffset(offset);
65 return true;
68 bool DBDataBuilder::FetchRecord(DBData &data, const IConverter *ic)
70 data = m_orig;
71 return true;
74 bool DBDataBuilder::EndOfFile() const
76 return true;
79 } // namespace Barry