1//! @file notation.hpp
2//! @author ryftchen
3//! @brief The declarations (notation) in the algorithm module.
4//! @version 0.1.0
5//! @copyright Copyright (c) 2022-2025 ryftchen. All rights reserved.
6
7#pragma once
8
9#include <cstdint>
10#include <string>
11
12//! @brief The algorithm module.
13namespace algorithm // NOLINT(modernize-concat-nested-namespaces)
14{
15//! @brief Notation-related functions in the algorithm module.
16namespace notation
17{
18//! @brief Brief function description.
19//! @return function description (module_function)
20inline static const char* description() noexcept
21{
22 return "ALGO_NOTATION";
23}
24extern const char* version() noexcept;
25
26//! @brief Notation methods.
27class Notation
28{
29public:
30 //! @brief Prefix.
31 //! @param infix - infix notation
32 //! @return prefix notation
33 static std::string prefix(const std::string_view infix);
34 //! @brief Postfix.
35 //! @param infix - infix notation
36 //! @return postfix notation
37 static std::string postfix(const std::string_view infix);
38
39private:
40 //! @brief Enumerate specific operator priorities.
41 enum class Priority : std::uint8_t
42 {
43 //! @brief None.
44 none,
45 //! @brief Low.
46 low,
47 //! @brief Medium.
48 medium,
49 //! @brief High.
50 high
51 };
52
53 //! @brief Convert infix notation to postfix notation.
54 //! @param infix - infix notation
55 //! @return postfix notation
56 static std::string infixToPostfix(const std::string_view infix);
57 //! @brief Get the operator priority.
58 //! @param c - character
59 //! @return operator priority
60 static Priority getPriority(const char c);
61 //! @brief Check whether the character is the operator.
62 //! @param c - character
63 //! @return be operator or not
64 static bool isOperator(const char c);
65};
66} // namespace notation
67} // namespace algorithm
68