Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6KB

  1. // Copyright 2021 Jean Pierre Cimalando
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // SPDX-License-Identifier: Apache-2.0
  16. //
  17. #pragma once
  18. #include <string>
  19. #include <cstdio>
  20. #include <cstddef>
  21. namespace ysfx {
  22. class text_reader
  23. {
  24. public:
  25. virtual ~text_reader() = default;
  26. virtual char read_next_char() = 0;
  27. virtual char peek_next_char() = 0;
  28. bool read_next_line(std::string &line);
  29. };
  30. //------------------------------------------------------------------------------
  31. class string_text_reader : public text_reader
  32. {
  33. public:
  34. explicit string_text_reader(const char *text) : m_char_ptr(text) {}
  35. char read_next_char() override;
  36. char peek_next_char() override;
  37. private:
  38. const char *m_char_ptr = nullptr;
  39. };
  40. //------------------------------------------------------------------------------
  41. class stdio_text_reader : public text_reader
  42. {
  43. public:
  44. explicit stdio_text_reader(FILE *stream) : m_stream(stream) {}
  45. char read_next_char() override;
  46. char peek_next_char() override;
  47. private:
  48. FILE *m_stream = nullptr;
  49. };
  50. } // namespace ysfx