libdap
Updated for version 3.17.0
|
00001 // -*- mode: c++; c-basic-offset:4 -*- 00002 00003 // This file is part of libdap, A C++ implementation of the OPeNDAP Data 00004 // Access Protocol. 00005 00006 // Copyright (c) 2013 OPeNDAP, Inc. 00007 // Author: James Gallagher <jgallagher@opendap.org> 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 // 00023 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. 00024 00025 #ifndef _d4_opaque_h 00026 #define _d4_opaque_h 1 00027 00028 #include <vector> 00029 00030 #include "BaseType.h" 00031 #include "InternalErr.h" 00032 00033 class Crc32; 00034 00035 namespace libdap 00036 { 00037 00038 class D4Opaque: public BaseType 00039 { 00040 public: 00041 typedef std::vector<uint8_t> dods_opaque; 00042 00043 protected: 00044 dods_opaque d_buf; 00045 00046 public: 00047 D4Opaque(const std::string &n) : BaseType(n, dods_opaque_c, true /*is_dap4*/), d_buf(0) { } 00048 D4Opaque(const std::string &n, const std::string &d) : BaseType(n, d, dods_opaque_c, true /*is_dap4*/), d_buf(0) { } 00049 00050 virtual ~D4Opaque() { } 00051 00052 D4Opaque(const D4Opaque ©_from) : BaseType(copy_from) { 00053 d_buf = copy_from.d_buf; 00054 } 00055 00056 D4Opaque &operator=(const D4Opaque &rhs); 00057 00058 virtual BaseType *ptr_duplicate() { return new D4Opaque(*this); } 00059 00060 virtual void clear_local_data(); 00061 00062 virtual unsigned int width(bool = false) const { return sizeof(vector<uint8_t>); } 00063 00064 // Return the length of the stored data or zero if no string has been 00065 // stored in the instance's internal buffer. 00066 virtual int length() const { return d_buf.size(); } 00067 00068 // DAP2 00069 virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool = true) { 00070 throw InternalErr(__FILE__, __LINE__, "Unimplemented method"); 00071 } 00072 virtual bool deserialize(UnMarshaller &, DDS *, bool = false) { 00073 throw InternalErr(__FILE__, __LINE__, "Unimplemented method"); 00074 } 00075 00076 // DAP4 00077 virtual void compute_checksum(Crc32 &checksum); 00078 virtual void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false); 00079 #if 0 00080 virtual void serialize_no_release(D4StreamMarshaller &m, DMR &dmr, bool filter = false); 00081 #endif 00082 virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr); 00083 00084 virtual unsigned int val2buf(void *val, bool reuse = false); 00085 virtual unsigned int buf2val(void **val); 00086 00087 virtual bool set_value(const dods_opaque &value); 00088 virtual dods_opaque value() const; 00089 00090 virtual void print_val(FILE *, std::string = "", bool = true) { 00091 throw InternalErr(__FILE__, __LINE__, "Unimplemented method"); 00092 } 00093 virtual void print_val(std::ostream &out, std::string space = "", bool print_decl_p = true); 00094 00095 //virtual void print_dap4(XMLWriter &xml, bool constrained = false); 00096 00097 virtual bool ops(BaseType *, int) { 00098 throw InternalErr(__FILE__, __LINE__, "Unimplemented method"); 00099 } 00100 00101 virtual void dump(std::ostream &strm) const ; 00102 }; 00103 00104 } // namespace libdap 00105 00106 #endif // _d4_opaque_h 00107