mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 00:25:44 +00:00
Make sure last field in infostring is still output even if it is empty
This commit is contained in:
parent
3520a9bd2c
commit
540e631fd5
@ -99,20 +99,31 @@ void InfoString::ToGdtProperties(const std::string& prefix, GdtEntry& gdtEntry)
|
||||
class InfoStringInputStream
|
||||
{
|
||||
std::istream& m_stream;
|
||||
int m_last_separator;
|
||||
|
||||
public:
|
||||
explicit InfoStringInputStream(std::istream& stream)
|
||||
: m_stream(stream)
|
||||
: m_stream(stream),
|
||||
m_last_separator(EOF)
|
||||
{
|
||||
}
|
||||
|
||||
bool NextField(std::string& value) const
|
||||
bool NextField(std::string& value)
|
||||
{
|
||||
std::ostringstream str;
|
||||
|
||||
auto c = m_stream.get();
|
||||
if (c == EOF)
|
||||
{
|
||||
if(m_last_separator != EOF)
|
||||
{
|
||||
m_last_separator = EOF;
|
||||
value = std::string();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
while (c != EOF && c != '\\')
|
||||
{
|
||||
@ -120,6 +131,7 @@ public:
|
||||
c = m_stream.get();
|
||||
}
|
||||
|
||||
m_last_separator = c;
|
||||
value = str.str();
|
||||
return true;
|
||||
}
|
||||
@ -127,7 +139,7 @@ public:
|
||||
|
||||
bool InfoString::FromStream(std::istream& stream)
|
||||
{
|
||||
const InfoStringInputStream infoStream(stream);
|
||||
InfoStringInputStream infoStream(stream);
|
||||
|
||||
std::string key;
|
||||
while (infoStream.NextField(key))
|
||||
@ -153,7 +165,7 @@ bool InfoString::FromStream(std::istream& stream)
|
||||
|
||||
bool InfoString::FromStream(const std::string& prefix, std::istream& stream)
|
||||
{
|
||||
const InfoStringInputStream infoStream(stream);
|
||||
InfoStringInputStream infoStream(stream);
|
||||
|
||||
std::string readPrefix;
|
||||
if (!infoStream.NextField(readPrefix))
|
||||
|
Loading…
x
Reference in New Issue
Block a user