diff options
author | unknown <tomas@poseidon.bredbandsbolaget.se> | 2004-06-04 08:24:42 +0000 |
---|---|---|
committer | unknown <tomas@poseidon.bredbandsbolaget.se> | 2004-06-04 08:24:42 +0000 |
commit | 9be85440427ae21e628a00772763147f07e730ff (patch) | |
tree | 990f2a02e0293f490a69a9ddd4130d628fb478e5 /ndb | |
parent | 65ee1426f45bcd010a01cbc4e545562ffe13afc6 (diff) | |
download | mariadb-git-9be85440427ae21e628a00772763147f07e730ff.tar.gz |
added operator<< for NdbRecAttr and removed attrtype from Event impl
ndb/include/ndbapi/NdbRecAttr.hpp:
operator << for NdbRecAttr
ndb/src/ndbapi/NdbEventOperationImpl.cpp:
removed print methid for ndbRecAttr in Event Impl
ndb/src/ndbapi/NdbEventOperationImpl.hpp:
removed print methid for ndbRecAttr in Event Impl
ndb/src/ndbapi/NdbRecAttr.cpp:
added operator<<
Diffstat (limited to 'ndb')
-rw-r--r-- | ndb/include/ndbapi/NdbRecAttr.hpp | 2 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbEventOperationImpl.cpp | 60 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbEventOperationImpl.hpp | 1 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbRecAttr.cpp | 88 |
4 files changed, 90 insertions, 61 deletions
diff --git a/ndb/include/ndbapi/NdbRecAttr.hpp b/ndb/include/ndbapi/NdbRecAttr.hpp index 0960c035abe..3aed62cb865 100644 --- a/ndb/include/ndbapi/NdbRecAttr.hpp +++ b/ndb/include/ndbapi/NdbRecAttr.hpp @@ -475,5 +475,7 @@ NdbRecAttr::isNULL() const return theNULLind; } +class NdbOut& operator <<(class NdbOut&, const NdbRecAttr &); + #endif diff --git a/ndb/src/ndbapi/NdbEventOperationImpl.cpp b/ndb/src/ndbapi/NdbEventOperationImpl.cpp index 7b4afc72ef7..b73a58d97c4 100644 --- a/ndb/src/ndbapi/NdbEventOperationImpl.cpp +++ b/ndb/src/ndbapi/NdbEventOperationImpl.cpp @@ -499,8 +499,7 @@ NdbEventOperationImpl::print() NdbRecAttr *p = theFirstRecAttrs[i]; ndbout << " %u " << i; while (p) { - ndbout << " : " << p->attrId() << " = "; - printRecAttr(p); + ndbout << " : " << p->attrId() << " = " << *p; p = p->next(); } ndbout << "\n"; @@ -1248,60 +1247,3 @@ NdbGlobalEventBuffer::real_wait(NdbGlobalEventBufferHandle *h, n += hasData(h->m_bufferIds[i]); return n; } - -/** - * TODO Change this function to use the real datatypes - * from NdbDictionary alternatively make a - * "printer" in NdbRecAttr that can be used from all programs - */ - -// and remove this include -#include "NdbSchemaOp.hpp" -void -NdbEventOperationImpl::printRecAttr(NdbRecAttr *p) -{ - int size = p->attrSize(); - int aSize = p->arraySize(); - - - switch(convertColumnTypeToAttrType(p->getType())){ - case UnSigned: - switch(size) { - case 8: ndbout << p->u_64_value(); break; - case 4: ndbout << p->u_32_value(); break; - case 2: ndbout << p->u_short_value(); break; - case 1: ndbout << (unsigned) p->u_char_value(); break; - default: ndbout << "Unknown size" << endl; - } - break; - - case Signed: - switch(size) { - case 8: ndbout << p->int64_value(); break; - case 4: ndbout << p->int32_value(); break; - case 2: ndbout << p->short_value(); break; - case 1: ndbout << (int) p->char_value(); break; - default: ndbout << "Unknown size" << endl; - } - break; - - case String: - { - char* buf = new char[aSize+1]; - memcpy(buf, p->aRef(), aSize); - buf[aSize] = 0; - ndbout << buf; - delete [] buf; - } - break; - - case Float: - ndbout << p->float_value(); - break; - - default: - ndbout << "Unknown"; - break; - } - -} diff --git a/ndb/src/ndbapi/NdbEventOperationImpl.hpp b/ndb/src/ndbapi/NdbEventOperationImpl.hpp index b7dee084a9f..f67c998e639 100644 --- a/ndb/src/ndbapi/NdbEventOperationImpl.hpp +++ b/ndb/src/ndbapi/NdbEventOperationImpl.hpp @@ -60,7 +60,6 @@ public: void print(); void printAll(); - void printRecAttr(NdbRecAttr *); Ndb *m_ndb; NdbEventImpl *m_eventImpl; diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 0f7baeac4f5..d323186ba58 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -27,7 +27,8 @@ Documentation: Adjust: 971206 UABRONM First version ************************************************************************************************/ #include <ndb_global.h> -#include "NdbRecAttr.hpp" +#include <NdbOut.hpp> +#include <NdbRecAttr.hpp> #include "NdbDictionaryImpl.hpp" NdbRecAttr::NdbRecAttr() : @@ -124,3 +125,88 @@ NdbRecAttr::clone() const { memcpy(ret->theRef, theRef, n); return ret; } + +NdbOut& operator <<(NdbOut& ndbout, const NdbRecAttr &r) +{ + if (r.isNULL()) + { + ndbout << "[NULL]"; + return ndbout; + } + + switch(r.getType()){ + + case NdbDictionary::Column::Bigunsigned: + ndbout << r.u_64_value(); + break; + case NdbDictionary::Column::Unsigned: + ndbout << r.u_32_value(); + break; + case NdbDictionary::Column::Smallunsigned: + ndbout << r.u_short_value(); + break; + case NdbDictionary::Column::Tinyunsigned: + ndbout << (unsigned) r.u_char_value(); + break; + case NdbDictionary::Column::Bigint: + ndbout << r.int64_value(); + break; + case NdbDictionary::Column::Int: + ndbout << r.int32_value(); + break; + case NdbDictionary::Column::Smallint: + ndbout << r.short_value(); + break; + case NdbDictionary::Column::Tinyint: + ndbout << (int) r.char_value(); + break; + + case NdbDictionary::Column::Char: + case NdbDictionary::Column::Varchar: + { + int aSize = r.arraySize(); + char* buf = new char[aSize+1]; + memcpy(buf, r.aRef(), aSize); + buf[aSize] = 0; + ndbout << buf; + delete [] buf; + } + break; + + case NdbDictionary::Column::Float: + ndbout << r.float_value(); + break; + case NdbDictionary::Column::Double: + ndbout << r.double_value(); + break; + case NdbDictionary::Column::Mediumint: + ndbout << "[Mediumint]"; + break; + case NdbDictionary::Column::Mediumunsigned: + ndbout << "[Mediumunsigend]"; + break; + case NdbDictionary::Column::Binary: + ndbout << "[Binary]"; + break; + case NdbDictionary::Column::Varbinary: + ndbout << "[Varbinary]"; + break; + case NdbDictionary::Column::Decimal: + ndbout << "[Decimal]"; + break; + case NdbDictionary::Column::Timespec: + ndbout << "[Timespec]"; + break; + case NdbDictionary::Column::Blob: + ndbout << "[Blob]"; + break; + case NdbDictionary::Column::Undefined: + ndbout << "[Undefined]"; + break; + default: + ndbout << "[unknown]"; + break; + } + + return ndbout; +} |