/*
 * SPDX-FileCopyrightText: 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
 *
 * SPDX-License-Identifier: LGPL-2.1-only
 *
 */

#ifndef LTTNG_CONFIG_CONFIG_INTERNAL_HPP
#define LTTNG_CONFIG_CONFIG_INTERNAL_HPP

#include <lttng/domain.h>

#include <vendor/optional.hpp>

#include <cstdint>
#include <libxml/xmlwriter.h>
#include <stdio.h>

struct config_writer {
	xmlTextWriterPtr writer;
};

namespace lttng {
namespace config {

/*
 * Return the domain type which the configuration string `text` (for example
 * `KERNEL` or `UST`) names, or `nonstd::nullopt` if `text` doesn't name a
 * domain type.
 */
nonstd::optional<lttng_domain_type> domain_type_from_string(const char *text) noexcept;

/*
 * Return the value of the decimal configuration string `text` as the
 * requested type, or `nonstd::nullopt` if `text` isn't a valid value in
 * range (rejecting trailing garbage).
 */
nonstd::optional<std::uint64_t> uint64_from_string(const char *text) noexcept;
nonstd::optional<std::int64_t> int64_from_string(const char *text) noexcept;
nonstd::optional<double> double_from_string(const char *text) noexcept;

} /* namespace config */
} /* namespace lttng */

#endif /* LTTNG_CONFIG_CONFIG_INTERNAL_HPP */
