Sha256: 1b1b386fba9ec58e20db47fb3073afc081122c44c8b0218cf5618cf57b2fe1ad

Contents?: true

Size: 1.33 KB

Versions: 38

Compression:

Stored size: 1.33 KB

Contents

#ifndef Rice__Symbol__hpp_
#define Rice__Symbol__hpp_

#include "Identifier.hpp"
#include "Object.hpp"
#include "detail/ruby.hpp"
#include <string>

namespace Rice
{

//! A wrapper for ruby's Symbol class.
/*! Symbols are internal identifiers in ruby.  They are singletons and
 *  can be thought of as frozen strings.  They differ from an Identifier
 *  in that they are in fact real Objects, but they can be converted
 *  back and forth between Identifier and Symbol.
 */
class Symbol
  : public Object
{
public:
  //! Wrap an existing symbol.
  Symbol(VALUE v);

  //! Wrap an existing symbol.
  Symbol(Object v);

  //! Construct a Symbol from an Identifier.
  Symbol(Identifier id);

  //! Construct a Symbol from a null-terminated C string.
  Symbol(char const * s = "");

  //! Construct a Symbol from an std::string.
  Symbol(std::string const & s);

  //! Return a string representation of the Symbol.
  char const * c_str() const;

  //! Return a string representation of the Symbol.
  std::string str() const;

  //! Return the Symbol as an Identifier.
  Identifier to_id() const;
};

} // namespace Rice

template<>
inline
Rice::Symbol from_ruby<Rice::Symbol>(Rice::Object x)
{
  return Rice::Symbol(x);
}

template<>
inline
Rice::Object to_ruby<Rice::Symbol>(Rice::Symbol const & x)
{
  return x;
}

#include "Symbol.ipp"

#endif // Rice__Symbol__hpp_

Version data entries

38 entries across 38 versions & 6 rubygems

Version Path
rice-3.0.0 rice/Symbol.hpp
rice2-2.2.1 rice/Symbol.hpp
rice2-2.2.0 rice/Symbol.hpp
rice-2.2.0 rice/Symbol.hpp
rice-2.1.3 rice/Symbol.hpp
rice-2.1.2 rice/Symbol.hpp
rice-2.1.1 rice/Symbol.hpp
rice-2.1.0 rice/Symbol.hpp
rice-2.0.0 rice/Symbol.hpp
rice-1.7.0 rice/Symbol.hpp
rice-1.6.3 rice/Symbol.hpp
jameskilton-rice-1.2.0 rice/Symbol.hpp
rice-1.6.2 rice/Symbol.hpp
rice-1.6.1 rice/Symbol.hpp
rice-1.6.0 rice/Symbol.hpp
rice-1.6.0.pre rice/Symbol.hpp
rice-1.5.3 rice/Symbol.hpp
rice-1.5.2 rice/Symbol.hpp
keyme-rice-1.5.1.keyme1 rice/Symbol.hpp
keyme-rice-1.5.1.keyme rice/Symbol.hpp