I'm working on a mixed code project - Custom DBX objects wrapped and used in vb.net, ala polysamp or even simplesquare examples.
I've got most things going good - lot of work but still, it's going. oddly one of the harder things to do is pass string data into the wrapper due to the curse of unicode. I'm sure there is a way to do this (i've seen the StringToWchar and WcharToString functions but failed to get use out of them).
Anyhow anyone got advice on this? I'll put all the (relavent) code below:
The variable in the custom object class:
const wchar_t* m_Suburb;
the get / set declarations in the class:
std::string getSuburb();
Acad::ErrorStatus setSuburb(std::string Suburb);
and [my attempts at] the definitions for them:
std::string SectionObject::getSuburb()
{
std::wstring ws;
ws = m_Suburb;
std::string str(ws.begin(),ws.end());
return str;
}
Acad::ErrorStatus SectionObject::setSuburb(std::string Suburb )
{
std::wstring widestr = std::wstring(Suburb.begin(), Suburb.end());
const wchar_t* widecstr = widestr.c_str();
m_Suburb=widecstr;
return Acad::eOk;
}
and the declaration for the wrapper of the property:
property std::string Suburb
{
std::string get ();
void set(std::string suburb);
}
...the definition of the wrapper:
std::string BCHF::SectionObjectWrap::mgSectionObject::Suburb::get()
{
return (GetImpObj()->getSuburb());
}
void BCHF::SectionObjectWrap::mgSectionObject::Suburb::set(std::string value)
{
Autodesk::AutoCAD::Runtime::Interop::Check(GetImpObj()->setSuburb(value));
}
and the only other relavent thing is the initialization in the constructor:
SectionObject::SectionObject () : m_SectNumber(1)
, m_Suburb(_T("s"))//<- here is the init for string - this i'm really making up, no idea how to initialize a wchar....
, m_ShowSectNumber(false)
, m_ShowArea(false)
, m_TxtMspace(0,0,0)
, m_TxtSizeMspace(0.0)
, m_Normal(0,0,1)
, m_pManaged(NULL) {
}
anyone else been here? I can't find much discussion about this, so any ideas appreciated :)
oh, and is there anyone to disable these smiley faces in code snippets?!?!? lol.