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.

63 lines
1.8KB

  1. /*************************************************************************************
  2. * Original code copyright (C) 2012 Steve Folta
  3. * Converted to Juce module (C) 2016 Leo Olivers
  4. * Forked from https://github.com/stevefolta/SFZero
  5. * For license info please see the LICENSE file distributed with this source code
  6. *************************************************************************************/
  7. #ifndef SFZREADER_H_INCLUDED
  8. #define SFZREADER_H_INCLUDED
  9. #include "SFZCommon.h"
  10. #include "CarlaJuceUtils.hpp"
  11. namespace sfzero
  12. {
  13. struct Region;
  14. class Sound;
  15. class Reader
  16. {
  17. public:
  18. explicit Reader(Sound *sound);
  19. ~Reader();
  20. void read(const water::File &file);
  21. void read(const char *text, unsigned int length);
  22. private:
  23. const char *handleLineEnd(const char *p);
  24. const char *readPathInto(water::String *pathOut, const char *p, const char *end);
  25. int keyValue(const water::String &str);
  26. int triggerValue(const water::String &str);
  27. int loopModeValue(const water::String &str);
  28. void finishRegion(Region *region);
  29. void error(const water::String &message);
  30. Sound *sound_;
  31. int line_;
  32. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Reader)
  33. };
  34. class StringSlice
  35. {
  36. public:
  37. StringSlice(const char *startIn, const char *endIn) : start_(startIn), end_(endIn) {}
  38. virtual ~StringSlice() {}
  39. unsigned int length() { return static_cast<unsigned int>(end_ - start_); }
  40. bool operator==(const char *other) { return (strncmp(start_, other, length()) == 0); }
  41. bool operator!=(const char *other) { return (strncmp(start_, other, length()) != 0); }
  42. const char *getStart() const { return start_; }
  43. const char *getEnd() const { return end_; }
  44. private:
  45. const char *start_;
  46. const char *end_;
  47. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StringSlice)
  48. };
  49. }
  50. #endif // SFZREADER_H_INCLUDED