Rice  1.5.2
 All Classes Files Functions Variables Typedefs Friends Pages
String.hpp
1 #ifndef Rice__String__hpp_
2 #define Rice__String__hpp_
3 
4 #include "Identifier.hpp"
5 #include "Builtin_Object_defn.hpp"
6 #include "to_from_ruby_defn.hpp"
7 #include "detail/ruby.hpp"
8 #include <string>
9 
10 namespace Rice
11 {
12 
14 
23 class String
24  : public Builtin_Object<RString, T_STRING>
25 {
26 public:
28  String();
29 
31  String(VALUE v);
32 
34  String(Object v);
35 
37  String(Identifier id);
38 
40  String(char const * s);
41 
43  String(std::string const & s);
44 
46  static String format(char const * s, ...);
47 
49 
51  size_t length() const;
52 
54 
57  char operator[](ptrdiff_t index) const;
58 
60  char const * c_str() const;
61 
63  std::string str() const;
64 
66 
69  Identifier intern() const;
70 };
71 
72 } // namespace Rice
73 
74 template<>
75 inline
76 Rice::String from_ruby<Rice::String>(Rice::Object x)
77 {
78  return Rice::String(x);
79 }
80 
81 template<>
82 inline
83 Rice::Object to_ruby<Rice::String>(Rice::String const & x)
84 {
85  return x;
86 }
87 
88 #include "Builtin_Object.ipp"
89 
90 #endif // Rice__String__hpp_
91 
A wrapper for the ID type.
Definition: Identifier.hpp:15
char const * c_str() const
Return a pointer to the beginning of the underlying C string.
char operator[](ptrdiff_t index) const
Get the character at the given index.
A smartpointer-like wrapper for Ruby builtin objects.
Definition: Builtin_Object_defn.hpp:18
static String format(char const *s,...)
Format a string using printf-style formatting.
std::string str() const
Return a copy of the string as an std::string.
A Wraper for the ruby String class.
Definition: String.hpp:23
Identifier intern() const
Create an Identifier from the String.
The base class for all Objects.
Definition: Object_defn.hpp:23
String()
Construct a new string.
size_t length() const
Get the length of the String.