X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdbms%2FShortBlock.cpp;fp=source%2Fdbms%2FShortBlock.cpp;h=a47de5f3cbe196a04e68ca76c9acaca8324e644c;hb=78be86969d2f26a9084b0c4af6ce43d5fa4ed3fd;hp=0000000000000000000000000000000000000000;hpb=a3b95648bd76140ef55e0b5941d423eee6c3856f;p=anna.git diff --git a/source/dbms/ShortBlock.cpp b/source/dbms/ShortBlock.cpp new file mode 100644 index 0000000..a47de5f --- /dev/null +++ b/source/dbms/ShortBlock.cpp @@ -0,0 +1,52 @@ +// ANNA - Anna is Not Nothingness Anymore // +// // +// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // +// // +// See project site at http://redmine.teslayout.com/projects/anna-suite // +// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // + + +#include + +#include + +using namespace anna; + +dbms::ShortBlock& dbms::ShortBlock::operator = (const dbms::ShortBlock & other) +throw(RuntimeException) { + if(this == &other) + return *this; + + if(other.isNull() == true) { + setNull(true); + return *this; + } + + return operator= (other.a_value); +} + +dbms::ShortBlock& dbms::ShortBlock::operator = (const anna::DataBlock & value) +throw(RuntimeException) { + if(value.getSize() > Data::getMaxSize()) { + throw RuntimeException( + functions::asString( + "Block out of range | Max: %d | Current: %d ", Data::getMaxSize(), value.getSize() + ), + ANNA_FILE_LOCATION + ); + } + + a_value = value; + setNull(a_value.isEmpty()); + return *this; +} + +std::string dbms::ShortBlock::asString() const +throw() { + std::string result("dbms::ShortBlock { "); + result += dbms::Data::asString(); + result += " | Value: "; + result += isNull() ? "(null)" : functions::asString(a_value).c_str(); + return result += " }"; +} +