32 lines
694 B
C++
32 lines
694 B
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: LineParser.hpp
|
|
Date: 2021-6-9
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
namespace Aurora::Parse
|
|
{
|
|
static void SplitNewlines(const AuString &in, std::function<void(const AuString &)> lineCallback)
|
|
{
|
|
AuMach index = 0;
|
|
AuString cpy = in;
|
|
|
|
while ((index = cpy.find("\n")) != AuString::npos)
|
|
{
|
|
auto line = cpy.substr(0, index);
|
|
cpy = cpy.substr(index + 1);
|
|
|
|
if (line[line.size() - 1] == '\r')
|
|
{
|
|
line.pop_back();
|
|
}
|
|
|
|
lineCallback(line);
|
|
}
|
|
|
|
lineCallback(cpy);
|
|
}
|
|
} |