replace FileLoader with TextLoader

This commit is contained in:
josh committed 2016-07-14 21:28:38 -04:00
1 parent cae0b581a2
commit a2bd7504b5
5 files changed
+68 -73

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
#ifndef TEXTLOADER_H
#define TEXTLOADER_H
#include <stdint.h>
#include <list>
#include <memory>
class TextLoader
{
public:
enum
{
LINE_ENDING_LF,
LINE_ENDING_CR,
LINE_ENDING_CRLF,
LINE_ENDING_COUNT
};
TextLoader();
void load_buffer(uint8_t * buffer, size_t size);
size_t num_lines()
{
if (m_lines == nullptr)
{
return 0u;
}
else
{
return m_lines->size();
}
}
int get_line_endings() { return m_line_endings; }
auto begin() { return m_lines->begin(); }
auto end() { return m_lines->end(); }
protected:
typedef std::pair<const uint8_t *, uint32_t> LineIndexPair;
typedef std::list<LineIndexPair> LineIndexPairList;
typedef std::shared_ptr<LineIndexPairList> LineIndexPairListRef;
int m_line_endings;
LineIndexPairListRef m_lines;
};
#endif