Normalize xml processing
[anna.git] / source / dbms / ShortBlock.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #include <anna/core/functions.hpp>
10
11 #include <anna/dbms/ShortBlock.hpp>
12
13 using namespace anna;
14
15 dbms::ShortBlock& dbms::ShortBlock::operator = (const dbms::ShortBlock & other)
16 throw(RuntimeException) {
17   if(this == &other)
18     return *this;
19
20   if(other.isNull() == true) {
21     setNull(true);
22     return *this;
23   }
24
25   return operator= (other.a_value);
26 }
27
28 dbms::ShortBlock& dbms::ShortBlock::operator = (const anna::DataBlock & value)
29 throw(RuntimeException) {
30   if(value.getSize() > Data::getMaxSize()) {
31     throw RuntimeException(
32       functions::asString(
33         "Block out of range | Max: %d | Current: %d ", Data::getMaxSize(), value.getSize()
34       ),
35       ANNA_FILE_LOCATION
36     );
37   }
38
39   a_value = value;
40   setNull(a_value.isEmpty());
41   return *this;
42 }
43
44 std::string dbms::ShortBlock::asString() const
45 throw() {
46   std::string result("dbms::ShortBlock { ");
47   result += dbms::Data::asString();
48   result += " | Value: ";
49   result += isNull() ? "(null)" : functions::asString(a_value).c_str();
50   return result += " }";
51 }
52