Rice  1.5.2
 All Classes Files Functions Variables Typedefs Friends Pages
Public Member Functions | Static Public Member Functions | List of all members
Rice::String Class Reference

A Wraper for the ruby String class. More...

#include <String.hpp>

Inheritance diagram for Rice::String:
Rice::Builtin_Object< RString, T_STRING > Rice::Object

Public Member Functions

 String ()
 Construct a new string.
 
 String (VALUE v)
 Wrap an existing string.
 
 String (Object v)
 Wrap an existing string.
 
 String (Identifier id)
 Construct a String from an Identifier.
 
 String (char const *s)
 Construct a String from a null-terminated C string.
 
 String (std::string const &s)
 Construct a String from an std::string.
 
size_t length () const
 Get the length of the String. More...
 
char operator[] (ptrdiff_t index) const
 Get the character at the given index. More...
 
char const * c_str () const
 Return a pointer to the beginning of the underlying C string.
 
std::string str () const
 Return a copy of the string as an std::string.
 
Identifier intern () const
 Create an Identifier from the String. More...
 
- Public Member Functions inherited from Rice::Builtin_Object< RString, T_STRING >
 Builtin_Object (Object value)
 Wrap an already allocated Ruby object. More...
 
 Builtin_Object (Builtin_Object const &other)
 Make a copy of a Builtin_Object. More...
 
RString & operator* () const
 Return a reference to obj_.
 
RString * operator-> () const
 Return a pointer to obj_.
 
RString * get () const
 Return a pointer to obj_.
 
void swap (Builtin_Object< RString, Builtin_Type > &ref)
 Swap with another builtin object of the same type. More...
 
- Public Member Functions inherited from Rice::Object
 Object (VALUE value=Qnil)
 Encapsulate an existing ruby object.
 
 Object (Object const &other)
 Copy constructor.
 
virtual ~Object ()
 Destructor.
 
bool test () const
 
 operator bool () const
 
bool is_nil () const
 Returns true if the object is nil, false otherwise.
 
 operator VALUE () const
 Implicit conversion to VALUE.
 
VALUE const volatile & value () const
 Explicitly get the encapsulated VALUE.
 
Class class_of () const
 Get the class of an object. More...
 
int compare (Object const &other) const
 Compare this object to another object. More...
 
String to_s () const
 Return a string representation of an object. More...
 
String inspect () const
 Inspect the object. More...
 
void freeze ()
 Freeze the object.
 
bool is_frozen () const
 Determine if the object is frozen. More...
 
void swap (Object &other)
 Swap with another Object.
 
Object instance_eval (String const &s)
 Evaluate the given string in the context of the object. More...
 
int rb_type () const
 Return the type of the underlying C object. More...
 
bool is_a (Object klass) const
 Determine whether the object is an instance of a class/module. More...
 
bool respond_to (Identifier id) const
 Determine if the objects responds to a method. More...
 
bool is_instance_of (Object klass) const
 Determine whether class is the object's class. More...
 
template<typename T >
void iv_set (Identifier name, T const &value)
 Set an instance variable. More...
 
Object iv_get (Identifier name) const
 Get the value of an instance variable. More...
 
Object attr_get (Identifier name) const
 Get the value of an instance variable, but don't warn if it is. More...
 
template<typename Retval_T >
Retval_T call (Identifier id, T1 arg1, T2 arg2,...) const
 Call the Ruby method specified by 'id' on object 'obj'. More...
 
Object call (Identifier id, T1 arg1, T2 arg2,...) const
 Version of call which defaults to Object return type.
 
Object vcall (Identifier id, Array args)
 Vectorized call. More...
 
void mark () const
 Mark the object with the garbage collector.
 

Static Public Member Functions

static String format (char const *s,...)
 Format a string using printf-style formatting.
 

Additional Inherited Members

- Protected Member Functions inherited from Rice::Object
void set_value (VALUE v)
 Set the encapsulated value.
 

Detailed Description

A Wraper for the ruby String class.

This class provides a C++-style interface to ruby's String class and its associated rb_str_* functions.

Example:

* String s(String::format("%s: %d", "foo", 42));
* std::cout << s.length() << std::endl;
*

Member Function Documentation

Identifier Rice::String::intern ( ) const

Create an Identifier from the String.

Calls rb_intern to create an ID.

Returns
an Identifier holding the ID returned from rb_intern.
size_t Rice::String::length ( ) const

Get the length of the String.

Returns
the length of the string.
char Rice::String::operator[] ( ptrdiff_t  index) const

Get the character at the given index.

Parameters
indexthe desired index.
Returns
the character at the given index.

The documentation for this class was generated from the following file: