Fix std::istream::streampos deprecation warning (#1154)

This commit is contained in:
vfjpl 2021-08-25 19:24:08 +02:00 committed by GitHub
parent e0d5b7d7fd
commit 1d614e294c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,23 +126,21 @@ private:
inline std::ostream& operator<<(std::ostream& out, const Color& color) inline std::ostream& operator<<(std::ostream& out, const Color& color)
{ {
using namespace std; return out << '#'
out << "#" << hex << setfill('0') << std::hex << std::setfill('0')
<< setw(2) << (int)color.r() << std::setw(2) << (int)color.r()
<< setw(2) << (int)color.g() << std::setw(2) << (int)color.g()
<< setw(2) << (int)color.b() << std::setw(2) << (int)color.b()
<< setw(2) << (int)color.a(); << std::setw(2) << (int)color.a()
out << dec << setfill(' '); << std::dec << std::setfill(' ');
return out;
} }
inline std::istream& operator>>(std::istream& in, Color& color) inline std::istream& operator>>(std::istream& in, Color& color)
{ {
using namespace std;
std::string tmp; std::string tmp;
if(in.get() == '#') { if(in.peek() == '#') {
in >> tmp; in.ignore() >> tmp;
if(tmp.length() == 6 || tmp.length() == 8) { if(tmp.length() == 6 || tmp.length() == 8) {
color.setRed((uint8)stdext::hex_to_dec(tmp.substr(0, 2))); color.setRed((uint8)stdext::hex_to_dec(tmp.substr(0, 2)));
@ -152,10 +150,10 @@ inline std::istream& operator>>(std::istream& in, Color& color)
color.setAlpha((uint8)stdext::hex_to_dec(tmp.substr(6, 2))); color.setAlpha((uint8)stdext::hex_to_dec(tmp.substr(6, 2)));
else else
color.setAlpha(255); color.setAlpha(255);
} else } else {
in.seekg(-(std::istream::streampos)tmp.length()-1, ios_base::cur); in.seekg(-tmp.length()-1, std::ios_base::cur);
}
} else { } else {
in.unget();
in >> tmp; in >> tmp;
if(tmp == "alpha") { if(tmp == "alpha") {
@ -197,7 +195,7 @@ inline std::istream& operator>>(std::istream& in, Color& color)
} else if(tmp == "orange") { } else if(tmp == "orange") {
color = Color::orange; color = Color::orange;
} else { } else {
in.seekg(-tmp.length(), ios_base::cur); in.seekg(-tmp.length(), std::ios_base::cur);
} }
} }
return in; return in;