Mercurial > hg > orthanc
diff Core/DicomFormat/DicomValue.h @ 1737:ec66a16aa398
removal of DicomStringValue and DicomNullValue
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 22 Oct 2015 07:52:24 +0200 |
parents | 6e7e5ed91c2d |
children | 15a788a63846 |
line wrap: on
line diff
--- a/Core/DicomFormat/DicomValue.h Wed Oct 21 16:52:23 2015 +0200 +++ b/Core/DicomFormat/DicomValue.h Thu Oct 22 07:52:24 2015 +0200 @@ -32,22 +32,77 @@ #pragma once -#include "../IDynamicObject.h" +#include "../OrthancException.h" #include <string> +#include <boost/noncopyable.hpp> namespace Orthanc { - class DicomValue : public IDynamicObject + class DicomValue : public boost::noncopyable { - public: - virtual DicomValue* Clone() const = 0; + private: + enum Type + { + Type_Null, + Type_String, + Type_Binary + }; + + Type type_; + std::string content_; + + DicomValue(const DicomValue& other) : + type_(other.type_), + content_(other.content_) + { + } - virtual std::string AsString() const = 0; + public: + DicomValue() : type_(Type_Null) + { + } + + DicomValue(const std::string& content, + bool isBinary) : + type_(isBinary ? Type_Binary : Type_String), + content_(content) + { + } + + DicomValue(const char* data, + size_t size, + bool isBinary) : + type_(isBinary ? Type_Binary : Type_String) + { + content_.assign(data, size); + } + + const std::string& GetContent() const + { + if (type_ == Type_Null) + { + throw OrthancException(ErrorCode_BadParameterType); + } + else + { + return content_; + } + } - virtual bool IsNull() const + bool IsNull() const + { + return type_ == Type_Null; + } + + bool IsBinary() const { - return false; + return type_ == Type_Binary; + } + + DicomValue* Clone() const + { + return new DicomValue(*this); } }; }