add WFObj::getLine()
This commit is contained in:
parent
d59eb2ffe5
commit
28722f4c94
31
WFObj.cc
31
WFObj.cc
@ -123,11 +123,10 @@ bool WFObj::load(const char *fname)
|
||||
|
||||
bool WFObj::load(const WFObj::Buffer &buff)
|
||||
{
|
||||
string buildup;
|
||||
while (istr.good())
|
||||
for (size_t idx = 0; idx < buff.size;)
|
||||
{
|
||||
istr.getline(buf, size+1);
|
||||
string input = trimString(buf);
|
||||
string line = getLine(buff, idx, &idx)
|
||||
string input = trimString(line);
|
||||
int sz = input.size();
|
||||
if (sz == 0 || input[0] == '#')
|
||||
continue;
|
||||
@ -145,6 +144,30 @@ bool WFObj::load(const WFObj::Buffer &buff)
|
||||
return true;
|
||||
}
|
||||
|
||||
string WFObj::getLine(const Buff & buff, size_t idx, size_t *update_idx)
|
||||
{
|
||||
size_t len = 0;
|
||||
while (idx + len < buff.length)
|
||||
{
|
||||
uint8_t ch = buff.data[idx + len];
|
||||
if (ch == 0)
|
||||
{
|
||||
*update_idx = idx + len + 1;
|
||||
break;
|
||||
}
|
||||
if (ch == '\r' || ch == '\n')
|
||||
{
|
||||
*update_idx = idx + len + 1;
|
||||
uint8_t nextch = buff.data[*update_idx];
|
||||
if (ch == '\r' && nextch == '\n')
|
||||
(*update_idx)++;
|
||||
break;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
return string((const char *) &buff.data[idx], len);
|
||||
}
|
||||
|
||||
void WFObj::processInputLine(const std::string & input)
|
||||
{
|
||||
string line = input;
|
||||
|
1
WFObj.h
1
WFObj.h
@ -77,6 +77,7 @@ protected:
|
||||
void parseVertexIndices(const std::string & vtxref, int * ret);
|
||||
void updateAABB(const float * const vertex);
|
||||
static Buffer loadfile(const char *path);
|
||||
std::string getLine(const Buff & buff, size_t idx, size_t *update_idx);
|
||||
|
||||
/* variables */
|
||||
std::vector< std::vector<std::string> > m_data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user