RtttlJsonListStream.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * RtttlJsonListStream.h - Support for streaming tune files in JSON format
8  *
9  * @author Sept 2019 mikee47 <mike@sillyhouse.net>
10  *
11  ****/
12 
13 #pragma once
14 
15 #include "RtttlParser.h"
17 
23 {
24 public:
30  RtttlJsonListStream(const String& name, RingTone::RtttlParser* parser) : name(name), parser(parser)
31  {
32  begin();
33  }
34 
36  {
37  delete parser;
38  }
39 
40  bool isValid() const override
41  {
42  return parser != nullptr;
43  }
44 
45  uint16_t readMemoryBlock(char* data, int bufSize) override;
46 
47  bool seek(int len) override;
48 
49  bool isFinished() override
50  {
51  return state >= 3;
52  }
53 
54  String getName() const override;
55 
56  unsigned getIndex()
57  {
58  return index;
59  }
60 
61 protected:
62  void begin();
63 
64 private:
65  String name;
66  String title;
67  RingTone::RtttlParser* parser;
68  uint8_t state = 0;
69  unsigned index = 0;
70  unsigned readPos = 0;
71 };
Base class for read-only stream.
Definition: DataSourceStream.h:46
Class to parse RTTTL files RTTTL (RingTone Text Transfer Language) format.
Definition: RtttlParser.h:57
A forward-only stream for listing contents of a tune file.
Definition: RtttlJsonListStream.h:23
~RtttlJsonListStream()
Definition: RtttlJsonListStream.h:35
unsigned getIndex()
Definition: RtttlJsonListStream.h:56
uint16_t readMemoryBlock(char *data, int bufSize) override
Read a block of memory.
bool seek(int len) override
Move read cursor.
String getName() const override
Returns name of the resource.
bool isFinished() override
Check if all data has been read.
Definition: RtttlJsonListStream.h:49
bool isValid() const override
Determine if the stream object contains valid data.
Definition: RtttlJsonListStream.h:40
RtttlJsonListStream(const String &name, RingTone::RtttlParser *parser)
Construct a list stream.
Definition: RtttlJsonListStream.h:30
The String class.
Definition: WString.h:137