Blame D4Opaque.h

Packit a4aae4
// -*- mode: c++; c-basic-offset:4 -*-
Packit a4aae4
Packit a4aae4
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
Packit a4aae4
// Access Protocol.
Packit a4aae4
Packit a4aae4
// Copyright (c) 2013 OPeNDAP, Inc.
Packit a4aae4
// Author: James Gallagher <jgallagher@opendap.org>
Packit a4aae4
//
Packit a4aae4
// This library is free software; you can redistribute it and/or
Packit a4aae4
// modify it under the terms of the GNU Lesser General Public
Packit a4aae4
// License as published by the Free Software Foundation; either
Packit a4aae4
// version 2.1 of the License, or (at your option) any later version.
Packit a4aae4
//
Packit a4aae4
// This library is distributed in the hope that it will be useful,
Packit a4aae4
// but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a4aae4
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit a4aae4
// Lesser General Public License for more details.
Packit a4aae4
//
Packit a4aae4
// You should have received a copy of the GNU Lesser General Public
Packit a4aae4
// License along with this library; if not, write to the Free Software
Packit a4aae4
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit a4aae4
//
Packit a4aae4
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
Packit a4aae4
Packit a4aae4
#ifndef _d4_opaque_h
Packit a4aae4
#define _d4_opaque_h 1
Packit a4aae4
Packit a4aae4
#include <vector>
Packit a4aae4
Packit a4aae4
#include "BaseType.h"
Packit a4aae4
#include "InternalErr.h"
Packit a4aae4
Packit a4aae4
class Crc32;
Packit a4aae4
Packit a4aae4
namespace libdap
Packit a4aae4
{
Packit a4aae4
Packit a4aae4
class D4Opaque: public BaseType
Packit a4aae4
{
Packit a4aae4
public:
Packit a4aae4
	typedef std::vector<uint8_t> dods_opaque;
Packit a4aae4
Packit a4aae4
protected:
Packit a4aae4
    dods_opaque d_buf;
Packit a4aae4
Packit a4aae4
public:
Packit a4aae4
    D4Opaque(const std::string &n) : BaseType(n, dods_opaque_c, true /*is_dap4*/), d_buf(0) { }
Packit a4aae4
    D4Opaque(const std::string &n, const std::string &d)  : BaseType(n, d, dods_opaque_c, true /*is_dap4*/), d_buf(0) { }
Packit a4aae4
Packit a4aae4
    virtual ~D4Opaque()  { }
Packit a4aae4
Packit a4aae4
    D4Opaque(const D4Opaque &copy_from) : BaseType(copy_from) {
Packit a4aae4
        d_buf = copy_from.d_buf;
Packit a4aae4
    }
Packit a4aae4
Packit a4aae4
    D4Opaque &operator=(const D4Opaque &rhs;;
Packit a4aae4
Packit a4aae4
    virtual BaseType *ptr_duplicate() {  return new D4Opaque(*this); }
Packit a4aae4
Packit a4aae4
    virtual void clear_local_data();
Packit a4aae4
Packit a4aae4
    virtual unsigned int width(bool = false) const { return sizeof(vector<uint8_t>); }
Packit a4aae4
Packit a4aae4
    // Return the length of the stored data or zero if no string has been
Packit a4aae4
    // stored in the instance's internal buffer.
Packit a4aae4
    virtual int length() const { return d_buf.size(); }
Packit a4aae4
Packit a4aae4
    // DAP2
Packit a4aae4
    virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool = true) {
Packit a4aae4
    	throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
Packit a4aae4
    }
Packit a4aae4
    virtual bool deserialize(UnMarshaller &, DDS *, bool = false) {
Packit a4aae4
    	throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
Packit a4aae4
    }
Packit a4aae4
Packit a4aae4
    // DAP4
Packit a4aae4
    virtual void compute_checksum(Crc32 &checksum);
Packit a4aae4
    virtual void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false);
Packit a4aae4
#if 0
Packit a4aae4
    virtual void serialize_no_release(D4StreamMarshaller &m, DMR &dmr, bool filter = false);
Packit a4aae4
#endif
Packit a4aae4
    virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
Packit a4aae4
Packit a4aae4
    virtual unsigned int val2buf(void *val, bool reuse = false);
Packit a4aae4
    virtual unsigned int buf2val(void **val);
Packit a4aae4
Packit a4aae4
    virtual bool set_value(const dods_opaque &value);
Packit a4aae4
    virtual dods_opaque value() const;
Packit a4aae4
Packit a4aae4
    virtual void print_val(FILE *, std::string = "", bool = true)  {
Packit a4aae4
    	throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
Packit a4aae4
    }
Packit a4aae4
    virtual void print_val(std::ostream &out, std::string space = "", bool print_decl_p = true);
Packit a4aae4
Packit a4aae4
    //virtual void print_dap4(XMLWriter &xml, bool constrained = false);
Packit a4aae4
Packit a4aae4
    virtual bool ops(BaseType *, int) {
Packit a4aae4
        throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
Packit a4aae4
    }
Packit a4aae4
Packit a4aae4
    virtual std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table);
Packit a4aae4
Packit a4aae4
    virtual void dump(std::ostream &strm) const ;
Packit a4aae4
Packit a4aae4
};
Packit a4aae4
Packit a4aae4
} // namespace libdap
Packit a4aae4
Packit a4aae4
#endif // _d4_opaque_h
Packit a4aae4