Blame parser-util.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) 2014 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
Packit a4aae4
#ifndef PARSER_UTIL_H_
Packit a4aae4
#define PARSER_UTIL_H_
Packit a4aae4
Packit a4aae4
namespace libdap {
Packit a4aae4
Packit a4aae4
/** Given a string (<tt>const char *src</tt>), save it to the
Packit a4aae4
    temporary variable pointed to by <tt>dst</tt>. If the string is
Packit a4aae4
    longer than <tt>ID_MAX</tt>, generate and error indicating that
Packit a4aae4
    <tt>src</tt> was truncated to <tt>ID_MAX</tt> characters during
Packit a4aae4
    the copy operation. There are two versions of this function; one
Packit a4aae4
    calls the version of <tt>parser_error()</tt> which writes to
Packit a4aae4
    stderr. The version which accepts the <tt>parser_arg *arg</tt>
Packit a4aae4
    argument calls the version of <tt>parser_error()</tt> which
Packit a4aae4
    generates and Error object.
Packit a4aae4
Packit a4aae4
    @return void
Packit a4aae4
    @brief Save a string to a temporary variable during the parse.
Packit a4aae4
    */
Packit a4aae4
Packit a4aae4
void save_str(char *dst, const char *src, const int line_num);
Packit a4aae4
void save_str(string &dst, const char *src, const int);
Packit a4aae4
Packit a4aae4
bool is_keyword(string id, const string &keyword);
Packit a4aae4
Packit a4aae4
/**
Packit a4aae4
 * @defgroup check_type
Packit a4aae4
 * @{
Packit a4aae4
 * @brief Can the given string be converted into a byte, ...?
Packit a4aae4
 */
Packit a4aae4
int check_byte(const char *val);
Packit a4aae4
int check_int16(const char *val);
Packit a4aae4
int check_uint16(const char *val);
Packit a4aae4
int check_int32(const char *val);
Packit a4aae4
int check_uint32(const char *val);
Packit a4aae4
int check_int64(const char *val);
Packit a4aae4
int check_uint64(const char *val);
Packit a4aae4
Packit a4aae4
int check_float32(const char *val);
Packit a4aae4
int check_float64(const char *val);
Packit a4aae4
Packit a4aae4
/** Currently this function always returns true.
Packit a4aae4
    @brief Is the value a valid URL? */
Packit a4aae4
int check_url(const char *val);
Packit a4aae4
Packit a4aae4
/** @} */
Packit a4aae4
Packit a4aae4
/**
Packit a4aae4
 * @defgroup get_type
Packit a4aae4
 * @{
Packit a4aae4
 * @brief Convert the string to a value; throw if the conversion fails.
Packit a4aae4
 */
Packit a4aae4
long long get_int64(const char *val);
Packit a4aae4
unsigned long long get_uint64(const char *val);
Packit a4aae4
double get_float64(const char *val);
Packit a4aae4
Packit a4aae4
/** @} */
Packit a4aae4
Packit a4aae4
} // namespace libdap
Packit a4aae4
Packit a4aae4
#endif /* PARSER_UTIL_H_ */