C++ 如何将Corba结构(包含“any”类型)复制到C++;结构
在Corba中,我有这样一个结构:C++ 如何将Corba结构(包含“any”类型)复制到C++;结构,c++,sqlite,struct,corba,C++,Sqlite,Struct,Corba,在Corba中,我有这样一个结构: module XYZ { typedef string AttributeName; struct AttributeColumn { AttributeName name; // Column attribute name any data; // Column attribute value }; typedef se
module XYZ {
typedef string AttributeName;
struct AttributeColumn {
AttributeName name; // Column attribute name
any data; // Column attribute value
};
typedef sequence <AttributeColumn> AttributeTable;
}
< >我想将这些值复制到C++结构中,它包括以下内容:
namespace DEF {
typedef std::string AttributeName;
typedef std::vector<std::string> StringCol;
struct AttributeColumn {
AttributeName name; // Column attribute name
StringCol str; // Column values if string
};
typedef std::vector<AttributeColumn> AttributeTable;
}
名称空间定义{
typedef std::字符串AttributeName;
typedef std::vector StringCol;
结构属性列{
AttributeName;//列属性名
StringCol str;//如果为字符串,则为列值
};
typedef std::vector AttributeTable;
}
以下是我的尝试:
XYZ::AttributeTable & xyz_table = getAttributeTable (); // This gives me the table containing the data from the database.
int rows = getLength ( xyz_table ); // This gives me the number of rows in the database.
DEF::AttributeTable def_table;
for (int i=0;i<rows;i++) {
def_table[i].name = xyz_table[i].name;
std::cout << def_table[i].name << std::endl;
xyz_table[i].data >>= def_table[i].str;
std::cout << def_table[i].str << std::endl;
}
XYZ::AttributeTable&XYZ_table=getAttributeTable();//这给了我一个包含数据库数据的表。
int rows=getLength(xyz_表);//这将提供数据库中的行数。
DEF::AttributeTable DEF_表;
for(inti=0;i='(操作数类型为'CORBA::Any'和'DEF::StringCol'{aka'std::vector'})
如果我注释掉for循环中的最后两行,那么代码会编译,但会崩溃。
因此,不知何故,复制到def_表中的“name”字段也无法正常工作。尝试以下操作:
namespace DEF {
typedef std::string AttributeName;
typedef std::vector<std::string> StringCol;
struct AttributeColumn {
AttributeName name; // Column attribute name
CORBA::Any str; // Column values if string
};
typedef std::vector<AttributeColumn> AttributeTable;
};
名称空间定义{
typedef std::字符串AttributeName;
typedef std::vector StringCol;
结构属性列{
AttributeName;//列属性名
CORBA::Any str;//如果字符串
};
typedef std::vector AttributeTable;
};
因为str需要是相同类型的数据。您使用的是哪种CORBA实现?您尝试过TAOX11吗?嗨,我对CORBA实现一无所知。我唯一可以访问的CORBA元素是.idl文件,我无法修改它。我如何发现该文件使用的是什么实现?哪个idl编译器您是否正在使用编译IDL文件,该IDL编译器与您的CORBA实现相关。此外,您还必须链接CORBA实现提供的一些CORBA库。也许《CORBA程序员指南》是一个良好的开端
ERROR: 1> error: no match for ‘operator>>=’ (operand types are ‘CORBA::Any’ and ‘DEF::StringCol’ {aka ‘std::vector<std::basic_string<char> >’})
namespace DEF {
typedef std::string AttributeName;
typedef std::vector<std::string> StringCol;
struct AttributeColumn {
AttributeName name; // Column attribute name
CORBA::Any str; // Column values if string
};
typedef std::vector<AttributeColumn> AttributeTable;
};