|
|
|
@ -9,6 +9,9 @@ |
|
|
|
|
@license LGPL, see file <a href="license.html">COPYING</a> |
|
|
|
|
|
|
|
|
|
$Log$ |
|
|
|
|
Revision 1.4 2004/12/20 07:40:36 marc |
|
|
|
|
documentation improved, new grouping |
|
|
|
|
|
|
|
|
|
Revision 1.3 2004/12/17 16:27:28 marc |
|
|
|
|
error in documentation: group forgotten |
|
|
|
|
|
|
|
|
@ -23,14 +26,35 @@ |
|
|
|
|
|
|
|
|
|
#include <string> |
|
|
|
|
#include <iostream> |
|
|
|
|
#include <algorithm> |
|
|
|
|
|
|
|
|
|
namespace mrw { |
|
|
|
|
|
|
|
|
|
/** @addtogroup StdExt
|
|
|
|
|
*/ |
|
|
|
|
//@{
|
|
|
|
|
/** @addtogroup StdExt
|
|
|
|
|
*/ |
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
/** @defgroup stdextReadline Read Line
|
|
|
|
|
|
|
|
|
|
The global functions mrw::getline read exactly one line from a |
|
|
|
|
stream, without the need of a buffer. It is therefore guaranteed |
|
|
|
|
that a whole line is read, regardless of the length of the |
|
|
|
|
line. The result is returned as std::string. |
|
|
|
|
|
|
|
|
|
@code |
|
|
|
|
// first syntax returns a string:
|
|
|
|
|
std::string line(mrw::readline(std::cin)); |
|
|
|
|
// second syntax returns the stream:
|
|
|
|
|
while (mrw::readline(std::cin, line)) |
|
|
|
|
std::cout<<"Read: "<<line<<std::endl; |
|
|
|
|
@endcode |
|
|
|
|
*/ |
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
/** @brief Deprecated! Do not use any more!
|
|
|
|
|
|
|
|
|
|
/** @brief get the lower of two values
|
|
|
|
|
@deprecated Use @c std::min from @c |
|
|
|
|
#include <algorithm> instead! |
|
|
|
|
|
|
|
|
|
Get the lower of two values. |
|
|
|
|
If both values are equal, @c a is returned. |
|
|
|
@ -42,10 +66,15 @@ namespace mrw { |
|
|
|
|
@pre @c T must support <code>bool operator>(conbst T&, constT&)</code> |
|
|
|
|
*/ |
|
|
|
|
template<typename T> const T& min(const T& a, const T& b) { |
|
|
|
|
return a > b ? b : a; |
|
|
|
|
/// calls @c std::min(a, b);
|
|
|
|
|
/// @deprecated will be removed in next major release
|
|
|
|
|
return std::min(a, b); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @brief get the higher of two values
|
|
|
|
|
/** @brief Deprecated! Do not use any more!
|
|
|
|
|
|
|
|
|
|
@deprecated Use @c std::max from @c |
|
|
|
|
#include <algorithm> instead! |
|
|
|
|
|
|
|
|
|
Get the higher of two values. |
|
|
|
|
If both values are equal, @c a is returned. |
|
|
|
@ -57,12 +86,15 @@ namespace mrw { |
|
|
|
|
@pre @c T must support <code>bool operator<(conbst T&, constT&)</code> |
|
|
|
|
*/ |
|
|
|
|
template<typename T> const T& max(const T& a, const T& b) { |
|
|
|
|
return a < b ? b : a; |
|
|
|
|
/// calls @c std::max(a, b);
|
|
|
|
|
/// @deprecated will be removed in next major release
|
|
|
|
|
return std::max(a, b); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @brief read one line from a stream
|
|
|
|
|
|
|
|
|
|
Reads one line from a stream, up to delimiter @c d. |
|
|
|
|
The delimiter is not appended to the string. |
|
|
|
|
|
|
|
|
|
@param is the stream to read from |
|
|
|
|
@param d the end of line delimiter |
|
|
|
@ -74,6 +106,7 @@ namespace mrw { |
|
|
|
|
/** @brief read one line from a stream
|
|
|
|
|
|
|
|
|
|
Reads one line from a stream, up to delimiter @c d. |
|
|
|
|
The delimiter is not appended to the string. |
|
|
|
|
|
|
|
|
|
@param is the stream to read from |
|
|
|
|
@param s the string to place the line in |
|
|
|
@ -85,4 +118,5 @@ namespace mrw { |
|
|
|
|
std::istream& getline(std::istream& is, std::string& s, char d = '\n'); |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
//@}
|
|
|
|
|
} |
|
|
|
|