bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
DapUtils.h
1// This file is part of bes, A C++ back-end server implementation framework
2// for the OPeNDAP Data Access Protocol.
3
4// Copyright (c) 2022 OPeNDAP
5// Author: James Gallagher <jgallagher@opendap.org>
6//
7// This library is free software; you can redistribute it and/or
8// modify it under the terms of the GNU Lesser General Public
9// License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11//
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15// Lesser General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public
18// License along with this library; if not, write to the Free Software
19// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21//
22// Created by James Gallagher on 4/6/22.
23//
24
25#ifndef BES_DAPUTILS_H
26#define BES_DAPUTILS_H
27
28#include <vector>
29#include <string>
30#include <memory>
31
32#include "AttrTable.h"
33#include "DDS.h"
34#include "DAS.h"
35
36namespace libdap {
37class DDS;
38class DMR;
39}
40
41namespace dap_utils {
42
43void log_response_and_memory_size(const std::string &caller_id, libdap::DDS *const *dds);
44
45void log_response_and_memory_size(const std::string &caller_id, /*const*/ libdap::DMR &dmr);
46void log_response_and_memory_size(const std::string &caller_id, /*const*/ libdap::XMLWriter &dmrpp_writer);
47
48void throw_for_dap4_typed_attrs(libdap::DAS *das, const std::string &file, unsigned int line);
49void throw_for_dap4_typed_vars_or_attrs(libdap::DDS *dds, const std::string &file, unsigned int line);
50
51uint64_t compute_response_size_and_inv_big_vars(const libdap::Constructor *ctr, uint64_t max_var_size, std::vector<std::string> &too_big);
52uint64_t compute_response_size_and_inv_big_vars(const libdap::D4Group *grp, uint64_t max_var_size, std::vector<std::string> &too_big);
53uint64_t compute_response_size_and_inv_big_vars(libdap::DMR &dmr, uint64_t max_var_size, std::vector<std::string> &too_big);
54
55void get_max_sizes_bytes(uint64_t &max_response_size_bytes, uint64_t &max_var_size_bytes, bool is_dap2=false);
56
57void throw_if_too_big(libdap::DMR &dmr, const std::string &file, unsigned int line);
58void throw_if_too_big(const libdap::DDS &dds, const std::string &file, unsigned int line);
59}
60#endif //BES_DAPUTILS_H