bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
NCMLUtil.h
1
2// This file is part of the "NcML Module" project, a BES module designed
3// to allow NcML files to be used to be used as a wrapper to add
4// AIS to existing datasets of any format.
5//
6// Copyright (c) 2009 OPeNDAP, Inc.
7// Author: Michael Johnson <m.johnson@opendap.org>
8//
9// For more information, please also see the main website: http://opendap.org/
10//
11// This library is free software; you can redistribute it and/or
12// modify it under the terms of the GNU Lesser General Public
13// License as published by the Free Software Foundation; either
14// version 2.1 of the License, or (at your option) any later version.
15//
16// This library is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19// Lesser General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public
22// License along with this library; if not, write to the Free Software
23// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24//
25// Please see the files COPYING and COPYRIGHT for more information on the GLPL.
26//
27// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
29#ifndef __NCML_MODULE_NCML_UTIL_H__
30#define __NCML_MODULE_NCML_UTIL_H__
31
45
46namespace libdap {
47// FDecls
48class BaseType;
49class Constructor;
50class DDS;
51class DAS;
52class AttrTable;
53}
54
55class BESDapResponse;
56
57#include <string>
58#include <vector>
59
60// If there isn't one defined yet, define a safe delete
61// to clear ptr after delete to avoid problems.
62#ifndef SAFE_DELETE
63#define SAFE_DELETE(a) { delete (a); (a) = 0; }
64#endif // SAFE_DELETE
65
66namespace ncml_module {
70class NCMLUtil {
71 NCMLUtil()
72 {
73 }
74public:
75 ~NCMLUtil()
76 {
77 }
78
80 static const std::string WHITESPACE;
81
86 static int tokenize(const std::string& str, std::vector<std::string>& tokens,
87 const std::string& delimiters = " \t");
88
90 static int tokenizeChars(const std::string& str, std::vector<std::string>& tokens);
91
95 static bool isAscii(const std::string& str);
96
98 static bool isAllWhitespace(const std::string& str);
99
102 static void trimLeft(std::string& str, const std::string& trimChars = WHITESPACE);
103
106 static void trimRight(std::string& str, const std::string& trimChars = WHITESPACE);
107
110 static void trim(std::string& str, const std::string& trimChars = WHITESPACE)
111 {
112 trimLeft(str, trimChars);
113 trimRight(str, trimChars);
114 }
115
119 static void trimAll(std::vector<std::string>& tokens, const std::string& trimChars = WHITESPACE);
120
127 static bool toUnsignedInt(const std::string& stringVal, unsigned int& oVal);
128
133 static void populateDASFromDDS(libdap::DAS* das, const libdap::DDS& dds_const);
134
141 static void copyVariablesAndAttributesInto(libdap::DDS* dds_out, const libdap::DDS& dds_in);
142
149 static libdap::DDS* getDDSFromEitherResponse(BESDapResponse* response);
150
151 static void hackGlobalAttributesForDAP2(libdap::AttrTable &global_attributes,
152 const std::string &global_container_name);
153
159 static void setVariableNameProperly(libdap::BaseType* pVar, const std::string& name);
160
161};
162// class NCMLUtil
163}// namespace ncml_module
164
165#endif /* __NCML_MODULE_NCML_UTIL_H__ */
Represents an OPeNDAP DAP response object within the BES.
static int tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" \t")
Definition NCMLUtil.cc:58
static libdap::DDS * getDDSFromEitherResponse(BESDapResponse *response)
Definition NCMLUtil.cc:356
static bool isAllWhitespace(const std::string &str)
Definition NCMLUtil.cc:105
static void trim(std::string &str, const std::string &trimChars=WHITESPACE)
Definition NCMLUtil.h:110
static int tokenizeChars(const std::string &str, std::vector< std::string > &tokens)
Definition NCMLUtil.cc:82
static bool toUnsignedInt(const std::string &stringVal, unsigned int &oVal)
Definition NCMLUtil.cc:135
static void populateDASFromDDS(libdap::DAS *das, const libdap::DDS &dds_const)
Definition NCMLUtil.cc:276
static void trimRight(std::string &str, const std::string &trimChars=WHITESPACE)
Definition NCMLUtil.cc:119
static void copyVariablesAndAttributesInto(libdap::DDS *dds_out, const libdap::DDS &dds_in)
Definition NCMLUtil.cc:332
static const std::string WHITESPACE
Definition NCMLUtil.h:80
static void setVariableNameProperly(libdap::BaseType *pVar, const std::string &name)
Definition NCMLUtil.cc:462
static void trimAll(std::vector< std::string > &tokens, const std::string &trimChars=WHITESPACE)
Definition NCMLUtil.cc:127
static bool isAscii(const std::string &str)
Definition NCMLUtil.cc:94
static void trimLeft(std::string &str, const std::string &trimChars=WHITESPACE)
Definition NCMLUtil.cc:110
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...