Frobby  0.9.0
FrobbyStringStream.h
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see http://www.gnu.org/licenses/.
16 */
17 #ifndef FROBBY_STRING_STREAM_GUARD
18 #define FROBBY_STRING_STREAM_GUARD
19 
20 #include <string>
21 #include <stdexcept>
22 
27  public:
28  FrobbyStringStream& operator<<(unsigned long integer);
29  FrobbyStringStream& operator<<(unsigned int integer);
30  FrobbyStringStream& operator<<(const mpz_class& integer);
31  FrobbyStringStream& operator<<(const string& text);
32  FrobbyStringStream& operator<<(const char* text);
33 
37  FrobbyStringStream& operator<<(char character);
38 
39  string& str();
40  const string& str() const;
41  operator const string&() const;
42 
43  void clear() {_str.clear();}
44 
45  static void appendIntegerToString(string& str, unsigned long integer);
46  static void appendIntegerToString(string& str, const mpz_class& integer);
47 
50  static void parseInteger(mpz_class& integer, const string& str);
51  class NotAnIntegerException : public runtime_error {
52  public:
53  NotAnIntegerException(const string&);
54  };
55 
56  private:
57  string _str;
58 };
59 
60 #endif
FrobbyStringStream & operator<<(unsigned long integer)
static void appendIntegerToString(string &str, unsigned long integer)
static void parseInteger(mpz_class &integer, const string &str)
Throws NotAnIntegerException if str is not the string representation of an integer.
A replacement for stringstream.