Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-04 00:29:23

0001 #include "CondCore/CondDB/interface/Binary.h"
0002 #include "CondCore/CondDB/interface/Exception.h"
0003 //
0004 #include "CoralBase/Blob.h"
0005 //
0006 #include <cstring>
0007 
0008 #include <cstring>
0009 #include <memory>
0010 #include <openssl/sha.h>
0011 
0012 cond::Binary::Binary() : m_data(new coral::Blob(0)) {}
0013 
0014 cond::Binary::Binary(const void* data, size_t size) : m_data(new coral::Blob(size)) {
0015   ::memcpy(m_data->startingAddress(), data, size);
0016 }
0017 
0018 cond::Binary::Binary(const coral::Blob& data) : m_data(new coral::Blob(data.size())) {
0019   ::memcpy(m_data->startingAddress(), data.startingAddress(), data.size());
0020 }
0021 
0022 cond::Binary::Binary(const Binary& rhs) : m_data(rhs.m_data) {}
0023 
0024 cond::Binary& cond::Binary::operator=(const Binary& rhs) {
0025   if (this != &rhs) {
0026     m_data = rhs.m_data;
0027   }
0028   return *this;
0029 }
0030 
0031 const coral::Blob& cond::Binary::get() const { return *m_data; }
0032 
0033 void cond::Binary::copy(const std::string& source) {
0034   m_data = std::make_shared<coral::Blob>(source.size());
0035   ::memcpy(m_data->startingAddress(), source.c_str(), source.size());
0036 }
0037 
0038 const void* cond::Binary::data() const {
0039   if (!m_data.get())
0040     throwException("Binary data can't be accessed.", "Binary::data");
0041   return m_data->startingAddress();
0042 }
0043 void* cond::Binary::data() {
0044   if (!m_data.get())
0045     throwException("Binary data can't be accessed.", "Binary::data");
0046   return m_data->startingAddress();
0047 }
0048 
0049 size_t cond::Binary::size() const {
0050   if (!m_data.get())
0051     throwException("Binary data can't be accessed.", "Binary::size");
0052   return m_data->size();
0053 }