Skip to content

Commit

Permalink
type_strings.hpp: use stdlib typedefs.
Browse files Browse the repository at this point in the history
darcs-hash:20070812153144-ec8c9-ce99ecc3a434ee290489fa32adbf79d2049b59e2.gz
  • Loading branch information
Eelis committed Aug 12, 2007
1 parent 07c0acf commit 9bb017e
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions prelude/type_strings.hpp
Expand Up @@ -25,6 +25,10 @@
#include <set>
#include <utility>
#include <deque>
#include <iostream>
#include <fstream>
#include <sstream>
#include <ios>
#include <boost/lexical_cast.hpp>
#include <boost/optional.hpp>
#include <boost/array.hpp>
Expand All @@ -41,8 +45,23 @@

// Note: Since type relies on passing the type as a template argument, it will not work for locally defined types.

template <> std::string type<std::string> () { return "string"; }
template <> std::string type<std::wstring> () { return "wstring"; }
#define TYPEDEF_TYPE(n) template <> std::string type<std::n> () { return #n; }

TYPEDEF_TYPE(ios)
TYPEDEF_TYPE(fstream)
TYPEDEF_TYPE(ifstream)
TYPEDEF_TYPE(ofstream)
TYPEDEF_TYPE(ostringstream)
TYPEDEF_TYPE(istringstream)
TYPEDEF_TYPE(stringstream)
TYPEDEF_TYPE(streambuf)
TYPEDEF_TYPE(iostream)
TYPEDEF_TYPE(ostream)
TYPEDEF_TYPE(istream)
TYPEDEF_TYPE(string)
TYPEDEF_TYPE(wstring)

#undef TYPEDEF_TYPE

// Demangling toys

Expand Down Expand Up @@ -103,6 +122,28 @@

#undef DEF_BUILTIN_SPEC

// stdlib typedefs

#define TYPEDEF_TYPE_DESC(n, pl, vow) \
template <> struct type_desc_t<std::n> \
{ static std::string s (bool b) { return b ? #n pl : #n; } enum { vowel = vow }; };

TYPEDEF_TYPE_DESC(ios, "es", true)
TYPEDEF_TYPE_DESC(fstream, "s", false)
TYPEDEF_TYPE_DESC(ifstream, "s", true)
TYPEDEF_TYPE_DESC(ofstream, "s", true)
TYPEDEF_TYPE_DESC(ostringstream, "s", true)
TYPEDEF_TYPE_DESC(istringstream, "s", true)
TYPEDEF_TYPE_DESC(stringstream, "s", false)
TYPEDEF_TYPE_DESC(streambuf, "s", false)
TYPEDEF_TYPE_DESC(iostream, "s", true)
TYPEDEF_TYPE_DESC(ostream, "s", true)
TYPEDEF_TYPE_DESC(istream, "s", true)
TYPEDEF_TYPE_DESC(string, "s", false)
TYPEDEF_TYPE_DESC(wstring, "s", false)

#undef TYPEDEF_TYPE_DESC

// primitive constructs

template <> struct type_desc_t<void>
Expand Down

0 comments on commit 9bb017e

Please sign in to comment.