Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Dynamic Object Creation

$
0
0
Normally I would create an object using operator=, as such:
docbook::db5::CsimplesectType pf_ss = pf.simplesect.append();


However, I have the need to create multiple instances of the object. e.g:
static std::vector<docbook::db5::CsimplesectType> object_vector(5);
            
for (unsigned int i = 0; i < object_vector.size() - 1; i++) {
    docbook::db5::CsimplesectType pf_ss[i] = pf.simplesect.append();
}


So that later I can populate the objects:
pf_ss1 = "whatever string"

OR
object_vector[1] = "whatever string"


Obviously, this doesn't work. I would prefer to be able to utilize a string name, as normal, to populate the object. How do I proceed?

Here is a snippet of the relevant header:
namespace docbook
{

namespace db5
{	

class CsimplesectType : public TypeBase
{
public:
	DOCBOOK_EXPORT CsimplesectType(xercesc::DOMNode* const& init);
	DOCBOOK_EXPORT CsimplesectType(CsimplesectType const& init);
	void operator=(CsimplesectType const& other) { m_node = other.m_node; }
	static conforme::meta::ComplexType StaticInfo() { return conforme::meta::ComplexType(types + _conforme_ti_db5_conforme_CsimplesectType); }

	MemberAttribute<string_type,_conforme_mi_db5_conforme_CsimplesectType_conforme_role, 0, 0> role;	// role CanySimpleType

	MemberAttribute<string_type,_conforme_mi_db5_conforme_CsimplesectType_conforme_id, 0, 0> id;	// id CID

	MemberAttribute<string_type,_conforme_mi_db5_conforme_CsimplesectType_conforme_version, 0, 0> version;	// version CanySimpleType
	MemberAttribute<string_type,_conforme_mi_db5_conforme_CsimplesectType_conforme_lang, 0, 1> lang;	// lang ClangType

	MemberAttribute<string_type,_conforme_mi_db5_conforme_CsimplesectType_conforme_base, 0, 0> base;	// base CanyURI
...


Viewing all articles
Browse latest Browse all 51036

Trending Articles