diff --git a/alib2cli/src/builtin/ReadFile.cpp b/alib2cli/src/builtin/ReadFile.cpp index 2664061efa16863d4a30af3220a60fdef0ef83fa..b3a93d675c1d6933754c7b68ad738c9822561c70 100644 --- a/alib2cli/src/builtin/ReadFile.cpp +++ b/alib2cli/src/builtin/ReadFile.cpp @@ -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 ( ) ) { diff --git a/alib2common/src/global/GlobalData.cpp b/alib2common/src/global/GlobalData.cpp index a96766db36be9c38d96b8931319534de3a3b643b..2c9d72971f166834ecc5f11f4e96e0d591b02ff2 100644 --- a/alib2common/src/global/GlobalData.cpp +++ b/alib2common/src/global/GlobalData.cpp @@ -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 */ diff --git a/alib2common/src/global/GlobalData.h b/alib2common/src/global/GlobalData.h index 1c017db2ba9dc1e74bc79132e01d0ff437c77fb5..6e81223596634076c7804ccfed0604a7448f5144 100644 --- a/alib2common/src/global/GlobalData.h +++ b/alib2common/src/global/GlobalData.h @@ -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_ */ diff --git a/alib2raw/src/factory/RawDataFactory.hpp b/alib2raw/src/factory/RawDataFactory.hpp index 6f9c6aa9f0ec0ce151a14e8d6168167087a149b9..9c333b18a4337bd351e6e7ca13b7ddcb1dd25bcd 100644 --- a/alib2raw/src/factory/RawDataFactory.hpp +++ b/alib2raw/src/factory/RawDataFactory.hpp @@ -68,7 +68,7 @@ public: public: template < class T > operator T ( ) { - return fromStream ( std::cin ); + return fromStream ( common::Streams::in ); } }; diff --git a/alib2str/src/factory/StringDataFactory.hpp b/alib2str/src/factory/StringDataFactory.hpp index 886077cbcc063a53919b253dc8bfb3ed98660807..e5126e8fcb79c053f169f8a8f569d1bfb8b45d04 100644 --- a/alib2str/src/factory/StringDataFactory.hpp +++ b/alib2str/src/factory/StringDataFactory.hpp @@ -53,7 +53,7 @@ public: public: template < class T > operator T ( ) { - return fromStream ( std::cin ); + return fromStream ( common::Streams::in ); } };