Commit 26c274c2 authored by Pavel Vainerman's avatar Pavel Vainerman

(MTR): переопределил operator<<(std::ostream& os,..) для типов.

parent d27a9114
...@@ -52,64 +52,50 @@ int main( int argc, const char **argv ) ...@@ -52,64 +52,50 @@ int main( int argc, const char **argv )
{ {
T3 t(v1,v2); T3 t(v1,v2);
cout << "(T3): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1] cout << "(T3): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1]
<< " --> " << (long)t << endl; << " --> " << t << endl;
} }
else if( !strcmp(type,"T4") ) else if( !strcmp(type,"T4") )
{ {
T4 t(v1); T4 t(v1);
cout << "(T4): v1=" << t.raw cout << "(T4): v1=" << t.raw
<< " --> " << t.sval << endl; << " --> " << t << endl;
} }
else if( !strcmp(type,"T5") ) else if( !strcmp(type,"T5") )
{ {
T5 t(v1,v2); T5 t(v1,v2);
cout << "(T5): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1] cout << "(T5): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1]
<< " --> " << t.raw.u2.val << " * 10^" << (int)t.raw.u2.exp << " --> " << t << endl;
<< " ===> " << t.val << endl;
} }
else if( !strcmp(type,"T6") ) else if( !strcmp(type,"T6") )
{ {
T6 t(v1,v2); T6 t(v1,v2);
cout << "(T6): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1] cout << "(T6): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1]
<< " --> " << t.raw.u2.val << " * 10^" << (int)t.raw.u2.exp << " --> " << t << endl;
<< " ===> " << t.val << endl;
} }
else if( !strcmp(type,"T7") ) else if( !strcmp(type,"T7") )
{ {
T7 t(v1,v2); T7 t(v1,v2);
cout << "(T7): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1] cout << "(T7): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1]
// << " --> " << T7.val << " * 10^-4" // << " --> " << T7.val << " * 10^-4"
<< " ===> " << t.val << " ===> " << t << endl;
<< " [" << ( t.raw.u2.ic == 0xFF ? "CAP" : "IND" ) << "|"
<< ( t.raw.u2.ie == 0xFF ? "EXP" : "IMP" ) << "]"
<< endl;
} }
else if( !strcmp(type,"T8") ) else if( !strcmp(type,"T8") )
{ {
T8 t(v1,v2); T8 t(v1,v2);
cout << "(T8): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1] cout << "(T8): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1]
<< " ===> " << setfill('0') << hex << " ===> " << t << endl;
<< setw(2) << t.hour() << ":" << setw(2) << t.min()
<< " " << setw(2) << t.day() << "/" << setw(2) << t.mon()
<< endl;
} }
else if( !strcmp(type,"T9") ) else if( !strcmp(type,"T9") )
{ {
T9 t(v1,v2); T9 t(v1,v2);
cout << "(T9): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1] cout << "(T9): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1]
<< " ===> " << setfill('0') << hex << " ===> " << t << endl;
<< setw(2) << t.hour() << ":" << setw(2) << t.min()
<< ":" << setw(2) << t.sec() << "." << setw(2) << t.ssec()
<< endl;
} }
else if( !strcmp(type,"T10") ) else if( !strcmp(type,"T10") )
{ {
T10 t(v1,v2); T10 t(v1,v2);
cout << "(T10): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1] cout << "(T10): v1=" << t.raw.v[0] << " v2=" << t.raw.v[1]
<< " ===> " << setfill('0') << dec << " ===> " << t << endl;
<< setw(4) << t.year() << "/" << setw(2) << t.mon()
<< "/" << setw(2) << t.day()
<< endl;
} }
else if( !strcmp(type,"F1") ) else if( !strcmp(type,"F1") )
{ {
......
...@@ -568,5 +568,76 @@ std::ostream& operator<<(std::ostream& os, MTR::T_Str16& t ) ...@@ -568,5 +568,76 @@ std::ostream& operator<<(std::ostream& os, MTR::T_Str16& t )
return os << t.sval; return os << t.sval;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
std::ostream& operator<<(std::ostream& os, MTR::T1& t )
{
return os << t.val;
}
std::ostream& operator<<(std::ostream& os, MTR::T2& t )
{
return os << t.val;
}
std::ostream& operator<<(std::ostream& os, MTR::T3& t )
{
return os << (long)(t);
}
std::ostream& operator<<(std::ostream& os, MTR::T4& t )
{
return os << t.sval;
}
std::ostream& operator<<(std::ostream& os, MTR::T5& t )
{
return os << t.raw.u2.val << " * 10^" << (int)t.raw.u2.exp
<< " [" << t.val << "]";
}
std::ostream& operator<<(std::ostream& os, MTR::T6& t )
{
return os << t.raw.u2.val << " * 10^" << (int)t.raw.u2.exp
<< " [" << t.val << "]";
}
std::ostream& operator<<(std::ostream& os, MTR::T7& t )
{
return os << t.val
<< " [" << ( t.raw.u2.ic == 0xFF ? "CAP" : "IND" ) << "|"
<< ( t.raw.u2.ie == 0xFF ? "EXP" : "IMP" ) << "]";
}
std::ostream& operator<<(std::ostream& os, MTR::T8& t )
{
return os << setfill('0') << hex
<< setw(2) << t.hour() << ":" << setw(2) << t.min()
<< " " << setw(2) << t.day() << "/" << setw(2) << t.mon();
}
std::ostream& operator<<(std::ostream& os, MTR::T9& t )
{
return os << setfill('0') << hex
<< setw(2) << t.hour() << ":" << setw(2) << t.min()
<< ":" << setw(2) << t.sec() << "." << setw(2) << t.ssec();
}
std::ostream& operator<<(std::ostream& os, MTR::T10& t )
{
return os << setfill('0') << dec
<< setw(4) << t.year() << "/" << setw(2) << t.mon()
<< "/" << setw(2) << t.day();
}
std::ostream& operator<<(std::ostream& os, MTR::T16& t )
{
return os << t.fval;
}
std::ostream& operator<<(std::ostream& os, MTR::T17& t )
{
return os << t.fval;
}
std::ostream& operator<<(std::ostream& os, MTR::F1& t )
{
return os << t.raw.val;
}
std::ostream& operator<<(std::ostream& os, MTR::T_Str8& t )
{
return os << t.sval;
}
std::ostream& operator<<(std::ostream& os, MTR::T_Str16& t )
{
return os << t.sval;
}
// ------------------------------------------------------------------------------------------
} // end of namespace MTR } // end of namespace MTR
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment