/*
 * SPDX-FileCopyrightText: 2023 Copyright contributors to the cppTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */
#ifndef TANGO_COMMON_VERSIONS_H_IN
#define TANGO_COMMON_VERSIONS_H_IN

// clang-format off
// The next lines are invalid C++ before the replacement
#define TANGO_VERSION_MAJOR @MAJOR_VERSION@
#define TANGO_VERSION_MINOR @MINOR_VERSION@
#define TANGO_VERSION_PATCH @PATCH_VERSION@

#define TANGO_IDL_VERSION_STR "@IDL_VERSION_FOUND@"
// clang-format on

/// Preprocessor checks for version dependent code
///
/// Usage:
///
/// ```
/// #if TANGO_VERSION >= TANGO_MAKE_VERSION(10, 3, 0)
/// // do something when compiling against cppTango 10.3.0 or higher
/// #elif TANGO_VERSION >= TANGO_MAKE_VERSION(9, 3, 0)
/// // LTS version
/// #else
/// // older versions
/// #endif
/// ```
/// @ingroup Macros
#ifndef TANGO_MAKE_VERSION
  #define TANGO_MAKE_VERSION(major, minor, patch) ((major) * 10000 + (minor) * 100 + (patch))
#endif // !TANGO_MAKE_VERSION

/// Return the current version, to be used together with @ref TANGO_MAKE_VERSION
/// @ingroup Macros
#ifndef TANGO_VERSION
  #define TANGO_VERSION TANGO_MAKE_VERSION(TANGO_VERSION_MAJOR, TANGO_VERSION_MINOR, TANGO_VERSION_PATCH)
#endif // !TANGO_VERSION

namespace Tango
{
#define TBS(s) #s
#define XTBS(s) TBS(s)

// NOLINTBEGIN(readability-identifier-naming)
const char *const TgLibVers = XTBS(TANGO_VERSION_MAJOR.TANGO_VERSION_MINOR.TANGO_VERSION_PATCH);
const char *const TgLibMajorVers = XTBS(TANGO_VERSION_MAJOR);

const int TgLibVersNb = (TANGO_VERSION_MAJOR * 10000) + (TANGO_VERSION_MINOR * 100) + TANGO_VERSION_PATCH;
// NOLINTEND(readability-identifier-naming)

#undef TBS
#undef XTBS

/// @brief The git revision of the source tree used to build this library.
///
/// A small, helper function returning the output of the "git describe" command
/// at the moment of building this library. If there was any error when trying
/// to obtain this information then it returns "unknown".
const char *git_revision();

} // namespace Tango

#endif
