// Copyright (C) 2002-2003 Gideon May (gideon@computer.org) // // Permission to copy, use, sell and distribute this software is granted // provided this copyright notice appears in all copies. // Permission to modify the code and to distribute modified code is granted // provided this copyright notice appears in all copies, and a notice // that the code was modified is included with the copyright notice. // // This software is provided "as is" without express or implied warranty, // and with no claim as to its suitability for any purpose. #include #include #include #include #include #include #include "held_ptr.hpp" using namespace boost::python; namespace { bool empty(osgText::String * self) { return self->empty(); } void pop_back(osgText::String * self) { self->pop_back(); } void push_back(osgText::String * self, int val) { self->push_back(val); } } namespace PyOSGText{ void init_String() { class_, bases, boost::noncopyable > string("String"); scope string_scope(string); string.def("set", (void (osgText::String::*)(const std::string&)) &osgText::String::set); string.def("set", (void (osgText::String::*)(const std::string&, osgText::String::Encoding)) &osgText::String::set); /** Set the text using a Unicode encoded std::string, which is converted to an internal TextString. * The encoding parameter specificies which Unicode encodeding is used in the std::string. */ string.def("createUTF8EncodedString", &osgText::String::createUTF8EncodedString); /** returns a UTF8 encoded version of this osgText::String.*/ string.def("push_back", &push_back); string.def("pop_back", &pop_back); string.def("empty", &empty); enum_ encoding("Encoding"); # define ENCODING(VALUE) \ (encoding.value(#VALUE, osgText::String::VALUE), \ string.def(#VALUE, object(osgText::String::VALUE))) ENCODING(ENCODING_UNDEFINED); ENCODING(ENCODING_ASCII); ENCODING(ENCODING_UTF8); ENCODING(ENCODING_UTF16); ENCODING(ENCODING_UTF16_BE); ENCODING(ENCODING_UTF16_LE); ENCODING(ENCODING_UTF32); ENCODING(ENCODING_UTF32_BE); ENCODING(ENCODING_UTF32_LE); ENCODING(ENCODING_SIGNATURE); } } #if 0 /** Set the text using a wchar_t string, * which is converted to an internal TextString.*/ void set(const wchar_t* text); #endif