Revert "Remove mysql and oracle resources for anna-ericsson project"
[anna.git] / source / dbms / ShortBlock.cpp
diff --git a/source/dbms/ShortBlock.cpp b/source/dbms/ShortBlock.cpp
new file mode 100644 (file)
index 0000000..a47de5f
--- /dev/null
@@ -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 <anna/core/functions.hpp>
+
+#include <anna/dbms/ShortBlock.hpp>
+
+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 += " }";
+}
+