jjones7947
April 16th, 2010, 06:57 AM
Doing Managed C++ Wrapper in VS2008. Have a native defined data structure as follows:
class API TF_StringList
{
public:
TF_StringList(const char* encoding = "cp_1252");
~TF_StringList();
TF_String* first_string() const {return start_string;}
TF_String* last_string() const {return end_string;}
void insert(const TF_String& aString);
void insert(const char* aString);
// If the length parameter is larger than the size of the string,
// The behavior is uncertain.
void insert(const tf_Byte* aString, size_t aByteLength);
void clear();
size_t size() const { return list_size; }
char* character_encoding;
private:
void set_first(TF_String* stringPtr) {start_string = stringPtr;}
void set_last (TF_String* stringPtr) {end_string = stringPtr;}
TF_String* start_string;
TF_String* end_string;
TF_String* curr_pos;
size_t list_size;
// Do not expose the copy constructor and the assignment operator.
TF_StringList(const TF_StringList& tmp);
TF_StringList& operator=(const TF_StringList& tmp);
};
In one of my managed functions I have parameter of List<String^> categoryList and I want to load an object of type TF_StringList with the elements of that parameter.
//Instantiate the TF_StringList
categories = new TF_StringList();
for(int i=0; i<categoryList.Count; i++)
{
const char* str = (const char*)(Marshal::StringToHGlobalAnsi(categoryList[i])).ToPointer();
categories->insert(str);
}
On the last line, I get the error:C2663: 'TF_StringList::insert' : 3 overloads have no legal conversion for 'this' pointer
First, The error would lead me to believe that str is not "seen" by the TF_StringList instance as a const char* since the insert(const char* aString) does not accept it.
Second, the list does not index out a Managed String (e.g. that String^ st = categoryList[i] is not valid). This seems unlikely since the declaration is List categoryList.
How can I check to find out what the problem actually is?
class API TF_StringList
{
public:
TF_StringList(const char* encoding = "cp_1252");
~TF_StringList();
TF_String* first_string() const {return start_string;}
TF_String* last_string() const {return end_string;}
void insert(const TF_String& aString);
void insert(const char* aString);
// If the length parameter is larger than the size of the string,
// The behavior is uncertain.
void insert(const tf_Byte* aString, size_t aByteLength);
void clear();
size_t size() const { return list_size; }
char* character_encoding;
private:
void set_first(TF_String* stringPtr) {start_string = stringPtr;}
void set_last (TF_String* stringPtr) {end_string = stringPtr;}
TF_String* start_string;
TF_String* end_string;
TF_String* curr_pos;
size_t list_size;
// Do not expose the copy constructor and the assignment operator.
TF_StringList(const TF_StringList& tmp);
TF_StringList& operator=(const TF_StringList& tmp);
};
In one of my managed functions I have parameter of List<String^> categoryList and I want to load an object of type TF_StringList with the elements of that parameter.
//Instantiate the TF_StringList
categories = new TF_StringList();
for(int i=0; i<categoryList.Count; i++)
{
const char* str = (const char*)(Marshal::StringToHGlobalAnsi(categoryList[i])).ToPointer();
categories->insert(str);
}
On the last line, I get the error:C2663: 'TF_StringList::insert' : 3 overloads have no legal conversion for 'this' pointer
First, The error would lead me to believe that str is not "seen" by the TF_StringList instance as a const char* since the insert(const char* aString) does not accept it.
Second, the list does not index out a Managed String (e.g. that String^ st = categoryList[i] is not valid). This seems unlikely since the declaration is List categoryList.
How can I check to find out what the problem actually is?