jes/src/core/TextLoader.h

45 lines
825 B
C++

#ifndef TEXTLOADER_H
#define TEXTLOADER_H
#include <stdint.h>
#include <list>
#include <memory>
#include "Span.h"
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(); }
bool get_eol_at_eof() { return m_eol_at_eof; }
protected:
int m_line_endings;
bool m_eol_at_eof;
std::shared_ptr<std::list<Span>> m_lines;
};
#endif