FileFormat.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * @brief Defines the base class for all file formats
  3. * @file aman/config/FileFormat.h
  4. * @author Sven Czarnian <devel@svcz.de>
  5. * @copyright Copyright 2021 Sven Czarnian
  6. * @license This project is published under the GNU General Public License v3 (GPLv3)
  7. */
  8. #pragma once
  9. #include <cstdint>
  10. #include <string>
  11. namespace aman {
  12. /**
  13. * @brief Defines the base class for all file formats
  14. * @ingroup format
  15. *
  16. * The base class provides error information, etc.
  17. */
  18. class FileFormat {
  19. protected:
  20. std::uint32_t m_errorLine; /**< Defines the line number if a parser detected an error */
  21. std::string m_errorMessage; /**< Defines the descriptive error message */
  22. /**
  23. * @brief Creates the default file format
  24. */
  25. FileFormat() noexcept;
  26. /**
  27. * @brief Resets the internal structures
  28. */
  29. void reset() noexcept;
  30. public:
  31. /**
  32. * @brief Checks if an error was found
  33. * @return True if an error was found, else false
  34. */
  35. bool errorFound() const noexcept;
  36. /**
  37. * @brief Returns the error line
  38. * @return The error line
  39. */
  40. std::uint32_t errorLine() const noexcept;
  41. /**
  42. * @brief Returns the error message
  43. * @return The error message
  44. */
  45. const std::string& errorMessage() const noexcept;
  46. };
  47. }