treat XMLCh properly using %typemaps_string
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8213 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
809530e8b1
commit
47a201bf89
5 changed files with 126 additions and 35 deletions
19
Examples/perl5/xmlstring/Makefile
Normal file
19
Examples/perl5/xmlstring/Makefile
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS = -lm
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile perl5_clean
|
||||
|
||||
check: all
|
||||
1
Examples/perl5/xmlstring/example.cxx
Normal file
1
Examples/perl5/xmlstring/example.cxx
Normal file
|
|
@ -0,0 +1 @@
|
|||
#include "example.h"
|
||||
36
Examples/perl5/xmlstring/example.h
Normal file
36
Examples/perl5/xmlstring/example.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include <xercesc/util/XMLString.hpp>
|
||||
|
||||
|
||||
class XMLChTest
|
||||
{
|
||||
XMLCh *_val;
|
||||
|
||||
public:
|
||||
|
||||
XMLChTest() : _val(0)
|
||||
{
|
||||
}
|
||||
|
||||
void set(const XMLCh *v)
|
||||
{
|
||||
size_t len = XERCES_CPP_NAMESPACE::XMLString::stringLen(v);
|
||||
delete[] _val;
|
||||
_val = new XMLCh[len + 1];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
_val[i] = v[i];
|
||||
}
|
||||
_val[len] = 0;
|
||||
}
|
||||
|
||||
const XMLCh *get()
|
||||
{
|
||||
return _val;
|
||||
}
|
||||
|
||||
XMLCh get_first()
|
||||
{
|
||||
return _val[0];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
10
Examples/perl5/xmlstring/example.i
Normal file
10
Examples/perl5/xmlstring/example.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module example
|
||||
|
||||
%include <xmlstring.i>
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
|
||||
%include example.h
|
||||
Loading…
Add table
Add a link
Reference in a new issue