Skip to content
Snippets Groups Projects
Commit 24e67db1 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

change std::cin to common::Streams::in

parent d2a1ce3a
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -9,6 +9,7 @@
#include <registration/AlgoRegistration.hpp>
#include <fstream>
#include <streambuf>
#include <global/GlobalData.h>
 
namespace cli {
 
......@@ -16,8 +17,8 @@ namespace builtin {
 
std::string ReadFile::read ( const std::string & filename ) {
if ( filename == "-" ) {
std::cin >> std::noskipws;
return std::string ( ( std::istreambuf_iterator < char > ( std::cin ) ), std::istreambuf_iterator < char > ( ) );
common::Streams::in >> std::noskipws;
return std::string ( ( std::istreambuf_iterator < char > ( common::Streams::in ) ), std::istreambuf_iterator < char > ( ) );
} else {
std::ifstream t ( filename );
if ( ! t.is_open ( ) ) {
......
......@@ -38,4 +38,14 @@ std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, std::
return os;
}
 
std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, std::ios_base & ( * func ) ( std::ios_base & ) ) {
os.get () << func;
return os;
}
std::istream & operator >> ( ext::reference_wrapper < std::istream > & is, std::ios_base & ( * func ) ( std::ios_base & ) ) {
is.get () >> func;
return is;
}
} /* namespace ext */
......@@ -51,6 +51,18 @@ std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, T &&
 
std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, std::ostream & ( * func ) ( std::ostream & ) );
 
std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, std::ios_base & ( * func ) ( std::ios_base & ) );
template < class T >
std::istream & operator >> ( ext::reference_wrapper < std::istream > & is, T & data ) {
is.get ( ) >> data;
return is;
}
std::istream & operator >> ( ext::reference_wrapper < std::istream > & is, std::ios_base & ( * func ) ( std::ios_base & ) );
} /* namespace ext */
 
#endif /* _GLOBAL_DATA_H_ */
......@@ -68,7 +68,7 @@ public:
public:
template < class T >
operator T ( ) {
return fromStream ( std::cin );
return fromStream ( common::Streams::in );
}
};
 
......
......@@ -53,7 +53,7 @@ public:
public:
template < class T >
operator T ( ) {
return fromStream ( std::cin );
return fromStream ( common::Streams::in );
}
};
 
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment