Added Util::Stricmp() and small tweak to serialization of Util::Format

This commit is contained in:
Bart Trzynadlowski 2016-08-24 04:10:20 +00:00
parent 2efe18b525
commit f08ad1584f
2 changed files with 18 additions and 1 deletions

View file

@ -67,4 +67,18 @@ namespace Util
{
return Hex(n, 2);
}
int Stricmp(const char *s1, const char *s2)
{
int cmp;
char c1;
char c2;
do
{
c1 = *s1++;
c2 = *s2++;
cmp = unsigned(tolower(c1)) - unsigned(tolower(c2));
} while ((cmp == 0) && (c1 != '\0') && (c2 != '\0'));
return cmp;
}
} // Util

View file

@ -31,7 +31,8 @@ namespace Util
void Write(std::ostream &os) const
{
os << m_stream.rdbuf();
if (m_stream.rdbuf()->in_avail())
os << m_stream.rdbuf();
}
template <typename T>
@ -98,6 +99,8 @@ namespace Util
std::string Hex(uint32_t n);
std::string Hex(uint16_t n);
std::string Hex(uint8_t n);
int Stricmp(const char *s1, const char *s2);
} // Util