FileDB.h 878 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2022, Itamar S. <itamar8910@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/DeprecatedString.h>
  8. #include <AK/StringView.h>
  9. namespace CodeComprehension {
  10. class FileDB {
  11. AK_MAKE_NONCOPYABLE(FileDB);
  12. AK_MAKE_NONMOVABLE(FileDB);
  13. public:
  14. virtual ~FileDB() = default;
  15. virtual Optional<DeprecatedString> get_or_read_from_filesystem(StringView filename) const = 0;
  16. void set_project_root(StringView project_root)
  17. {
  18. if (project_root.is_null())
  19. m_project_root.clear();
  20. else
  21. m_project_root = project_root;
  22. }
  23. Optional<DeprecatedString> const& project_root() const { return m_project_root; }
  24. DeprecatedString to_absolute_path(StringView filename) const;
  25. protected:
  26. FileDB() = default;
  27. private:
  28. Optional<DeprecatedString> m_project_root;
  29. };
  30. }