Go Back   ZeroC Forums > Bug Reports

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 01-15-2008
paolo paolo is offline
Registered User
 
Name: paolo volpi
Organization: tvblob
Project: tvblob blobbox
 
Join Date: Aug 2007
Posts: 19
slice2freeze std::wstring

Consider this simple ice definition:

["cpp:type:wstring"]
module syn
{
struct UserDataT
{
string username;
};
};

Genereting a Freeze Map with:

slice2freeze --dict UsersMap,int,syn::UserDataT --dict-index UsersMap,username UserMap syn.ice

This is the header generated:

#ifndef __UserMap_h__
#define __UserMap_h__

#include <Freeze/Map.h>
#include <syn.h>

#ifndef ICE_IGNORE_VERSION
# if ICE_INT_VERSION / 100 != 302
# error Ice version mismatch!
# endif
# if ICE_INT_VERSION % 100 > 50
# error Beta header file detected
# endif
# if ICE_INT_VERSION % 100 < 1
# error Ice patch level mismatch!
# endif
#endif

class UsersMapKeyCodec
{
public:

static void write(::Ice::Int, Freeze::Key&, const ::Ice::CommunicatorPtr&);
static void read(::Ice::Int&, const Freeze::Key&, const ::Ice::CommunicatorPtr&);
static const std::string& typeId();
};

class UsersMapValueCodec
{
public:

static void write(const ::syn::UserDataT&, Freeze::Value&, const ::Ice::CommunicatorPtr&);
static void read(::syn::UserDataT&, const Freeze::Value&, const ::Ice::CommunicatorPtr&);
static const std::string& typeId();
};

class UsersMap : public Freeze::Map< ::Ice::Int, ::syn::UserDataT, UsersMapKeyCodec, UsersMapValueCodec, Freeze::IceEncodingCompare >
{
public:


class UsernameIndex : public Freeze::MapIndex< ::std::string, UsernameIndex, Freeze::IceEncodingCompare >
{
public:

UsernameIndex(const std::string&, const Freeze::IceEncodingCompare& = Freeze::IceEncodingCompare());

static void write(const ::std::string&, Freeze::Key&, const Ice::CommunicatorPtr&);
static void read(::std::string&, const Freeze::Key&, const ::Ice::CommunicatorPtr&);

protected:

virtual void marshalKey(const Freeze::Value&, Freeze::Key&) const;
};

UsersMap(const Freeze::ConnectionPtr&, const std::string&, bool = true, const Freeze::IceEncodingCompare& = Freeze::IceEncodingCompare());

template <class _InputIterator>
UsersMap(const Freeze::ConnectionPtr& __connection, const std::string& __dbName, bool __createDb, _InputIterator __first, _InputIterator __last, const Freeze::IceEncodingCompare& __compare = Freeze::IceEncodingCompare())
: Freeze::Map< ::Ice::Int, ::syn::UserDataT, UsersMapKeyCodec, UsersMapValueCodec, Freeze::IceEncodingCompare >(__connection->getCommunicator())
{
Freeze::KeyCompareBasePtr __keyCompare = new Freeze::KeyCompare< ::Ice::Int, UsersMapKeyCodec, Freeze::IceEncodingCompare >(__compare, this->_communicator);
std::vector<Freeze::MapIndexBasePtr> __indices;
__indices.push_back(new UsernameIndex("username"));
this->_helper.reset(Freeze::MapHelper::create(__connect ion, __dbName, UsersMapKeyCodec::typeId(), UsersMapValueCodec::typeId(), __keyCompare, __indices, __createDb));
while(__first != __last)
{
put(*__first);
++__first;
}
}

iterator findByUsername(const ::std::string&, bool = true);
const_iterator findByUsername(const ::std::string&, bool = true) const;
iterator lowerBoundForUsername(const ::std::string&);
const_iterator lowerBoundForUsername(const ::std::string&) const;
iterator upperBoundForUsername(const ::std::string&);
const_iterator upperBoundForUsername(const ::std::string&) const;
std:air<iterator, iterator> equalRangeForUsername(const ::std::string&);
std:air<const_iterator, const_iterator> equalRangeForUsername(const ::std::string&) const;
int usernameCount(const ::std::string&) const;
};

As you can see for example findByUsername first parameter is mapped to std::string instead of std::wstring.

I think this is not correct, isn't it?

Last edited by paolo : 01-15-2008 at 06:09 AM.
Reply With Quote
  #2 (permalink)  
Old 01-15-2008
dwayne's Avatar
dwayne dwayne is offline
ZeroC Staff
 
Name: Dwayne Boone
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Jan 2005
Location: St. John's, Newfoundland
Posts: 209
Thanks for the report. We will look into this.

Dwayne
Reply With Quote
  #3 (permalink)  
Old 01-15-2008
paolo paolo is offline
Registered User
 
Name: paolo volpi
Organization: tvblob
Project: tvblob blobbox
 
Join Date: Aug 2007
Posts: 19
The problem is in slice2freeze sources where the function :

string
InputTypeToString(const TypePtr& type, bool useWstring, const StringList& metaData)

is called every time with useWstring=false.
Reply With Quote
  #4 (permalink)  
Old 01-15-2008
bernard's Avatar
bernard bernard is offline
ZeroC Staff
 
Name: Bernard Normier
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Palm Beach Gardens, FL
Posts: 813
Hi Paolo,

Yes, it's definitely a bug, but it's not that easy to fix. Here is a work-around that should work well, but it also requires a small bug fix to slice2freeze.

1) slice2freeze bug fix: on line 933 of slice2freeze/Main.cpp, insert:
iType.metaData = dataMember->getMetaData();

and then rebuild slice2freeze (you may need to start a full Ice build if you haven't one already)

2) Instead or in addition to the module-level [["cpp:type:wstring"]] metadata, add a wstring metadata to all the data members you want to index. With your example, this would be:

["cpp:type:wstring"]
module syn
{
struct UserDataT
{
["cpp:type:wstring"] string username;
};
};

Please let us know how it goes!

Bernard
__________________
Bernard Normier
ZeroC, Inc.
Reply With Quote
  #5 (permalink)  
Old 01-16-2008
paolo paolo is offline
Registered User
 
Name: paolo volpi
Organization: tvblob
Project: tvblob blobbox
 
Join Date: Aug 2007
Posts: 19
Thanks a lot, that patch solved the problem
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
std::string in interface dthompson Help Center 1 06-21-2006 05:49 PM
Casting char* to std::string inmmat Help Center 5 06-10-2006 02:43 PM
Status on wstring? jgaa Help Center 2 03-21-2005 09:59 PM
ICE std-ization? marlowa Comments 3 03-21-2005 05:41 PM
non-std scandir function marlowa Patches 1 02-28-2003 02:28 PM


All times are GMT -4. The time now is 07:41 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.