function printAccessorsAndMutators(&$bag, &$needsContents, &$indent) { global $_globals; global $meta; $content_type = $bag['content_type']; $pre = ''; getTypeNameAndPrefix($content_type, $pre); if ($_globals['accessorsAndMutators'] && ($bag['useXMLNS'] || count($bag['attributes']) > 0 || count($bag['elements']) > 0 || ($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'])) { //generate accessors and mutators for everything print "\n" . $indent . "public:\t//Accessors and Mutators\n"; if ($bag['isExtension']) { printAttributes($meta[$bag['base_type']], $typemeta, $indent, !$meta[$bag['base_type']]['isAComplexType']); } printAttributes($bag, $typemeta, $indent, !$bag['isAComplexType']); for ($i = 0; $i < count($bag['elements']); $i++) { $maxOccurs = $bag['element_attrs'][$bag['elements'][$i]]['maxOccurs']; $maxOccurs = $maxOccurs == 'unbounded' || $maxOccurs > 1; $type = ''; if (isset($bag['element_attrs'][$bag['elements'][$i]]['type']) && isset($meta[$bag['element_attrs'][$bag['elements'][$i]]['type']])) { $type = $_globals['prefix'] . ucfirst($bag['element_attrs'][$bag['elements'][$i]]['type']) . ($maxOccurs ? "_Array" : "Ref"); } else { $type = $_globals['prefix'] . ucfirst($bag['elements'][$i]) . ($maxOccurs ? "_Array" : "Ref"); } $name = ucfirst($bag['elements'][$i]) . ($maxOccurs ? "_array" : ""); if ($maxOccurs) { //comment print $indent . "\t/**\n" . $indent . "\t * Gets the " . $bag['elements'][$i] . " element array.\n"; print $indent . "\t * @return Returns a reference to the array of " . $bag['elements'][$i] . " elements.\n"; print $indent . "\t */\n"; //code print $indent . "\t" . $type . " &get" . $name . "() { return elem" . $name . "; }\n"; //comment print $indent . "\t/**\n" . $indent . "\t * Gets the " . $bag['elements'][$i] . " element array.\n"; print $indent . "\t * @return Returns a constant reference to the array of " . $bag['elements'][$i] . " elements.\n"; print $indent . "\t */\n"; //code print $indent . "\tconst " . $type . " &get" . $name . "() const { return elem" . $name . "; }\n"; //print $indent ."\tvoid set". $name ."( ". $type ." *e". $name ." ) { elem". $name ." = *e". $name ."; }\n\n"; } else { //comment print $indent . "\t/**\n" . $indent . "\t * Gets the " . $bag['elements'][$i] . " element.\n"; print $indent . "\t * @return a daeSmartRef to the " . $bag['elements'][$i] . " element.\n"; print $indent . "\t */\n"; //code print $indent . "\tconst " . $type . " get" . $name . "() const { return elem" . $name . "; }\n"; //print $indent ."\tvoid set". $name ."( ". $type ." &e". $name ." ) { elem". $name ." = e". $name ."; }\n\n"; } if (isset($meta[$bag['elements'][$i]])) { if (count($meta[$bag['elements'][$i]]['substitutableWith']) > 0) { $needsContents = true; } } } if ($bag['hasChoice'] || $needsContents || $bag['has_any']) { //comment print $indent . "\t/**\n" . $indent . "\t * Gets the _contents array.\n"; print $indent . "\t * @return Returns a reference to the _contents element array.\n"; print $indent . "\t */\n"; //code print $indent . "\tdaeElementRefArray &getContents() { return _contents; }\n"; //comment print $indent . "\t/**\n" . $indent . "\t * Gets the _contents array.\n"; print $indent . "\t * @return Returns a constant reference to the _contents element array.\n"; print $indent . "\t */\n"; //code print $indent . "\tconst daeElementRefArray &getContents() const { return _contents; }\n\n"; } if (($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract']) { $type = $content_type; if ($meta[$content_type]['isAComplexType']) { $type = $type . "Ref"; } $baseStringTypes = "xsDateTime xsID xsNCName xsNMTOKEN xsName xsToken xsString domSidref domSid"; $baseType = $pre . ucfirst($type); if (isset($typemeta[$type])) { $typeInfo = $typemeta[$type]; while ($typeInfo['base'] != '' && isset($typemeta[$typeInfo['base']])) { $typeInfo = $typemeta[$typeInfo['base']]; if (preg_match("/xs\\:/", $typeInfo['type'])) { $baseType = "xs" . ucfirst(substr($typeInfo['type'], 3)); } else { $baseType = $_globals['prefix'] . ucfirst($typeInfo['type']); } } } //if ( !strcmp( $pre . ucfirst( $type ), $full_element_name ) ) { if ($bag['parent_meta']['inline_elements'] != NULL && array_key_exists($type, $bag['parent_meta']['inline_elements'])) { $pre = '::' . $pre; } if (!isset($bag['baseTypeViaRestriction'])) { if (isset($typemeta[$content_type]) && $typemeta[$content_type]['isArray'] || $content_type == 'IDREFS') { //comment print $indent . "\t/**\n" . $indent . "\t * Gets the _value array.\n"; print $indent . "\t * @return Returns a " . $pre . ucfirst($type) . " reference of the _value array.\n"; print $indent . "\t */\n"; //code print $indent . "\t" . $pre . ucfirst($type) . " &getValue() { return _value; }\n"; //comment print $indent . "\t/**\n" . $indent . "\t * Gets the _value array.\n"; print $indent . "\t * @return Returns a constant " . $pre . ucfirst($type) . " reference of the _value array.\n"; print $indent . "\t */\n"; //code print $indent . "\tconst " . $pre . ucfirst($type) . " &getValue() const { return _value; }\n"; //comment print $indent . "\t/**\n" . $indent . "\t * Sets the _value array.\n"; print $indent . "\t * @param val The new value for the _value array.\n"; print $indent . "\t */\n"; //code print $indent . "\tvoid setValue( const " . $pre . ucfirst($type) . " &val ) { _value = val; }\n\n"; //print $indent ."\t _meta->getValueAttribute()->setIsValid(true); }\n\n"; } else { if (ucfirst($type) == 'AnyURI') { //comment print $indent . "\t/**\n" . $indent . "\t * Gets the value of this element.\n"; print $indent . "\t * @return Returns a " . $pre . ucfirst($type) . " of the value.\n"; print $indent . "\t */\n"; //code print $indent . "\t" . $pre . ucfirst($type) . " &getValue() { return _value; }\n"; //comment print $indent . "\t/**\n" . $indent . "\t * Gets the value of this element.\n"; print $indent . "\t * @return Returns a constant " . $pre . ucfirst($type) . " of the value.\n"; print $indent . "\t */\n"; //code print $indent . "\tconst " . $pre . ucfirst($type) . " &getValue() const { return _value; }\n"; //comment print $indent . "\t/**\n" . $indent . "\t * Sets the _value of this element.\n"; print $indent . "\t * @param val The new value for this element.\n"; print $indent . "\t */\n"; //code print $indent . "\tvoid setValue( const " . $pre . ucfirst($type) . " &val ) { _value = val; }\n"; // We add a setter that takes a plain string to help with backward compatibility //comment print $indent . "\t/**\n" . $indent . "\t * Sets the _value of this element.\n"; print $indent . "\t * @param val The new value for this element.\n"; print $indent . "\t */\n"; //code print $indent . "\tvoid setValue( xsString val ) { _value = val; }\n\n"; } else { if (ucfirst($type) == 'IDREF') { //comment print $indent . "\t/**\n" . $indent . "\t * Gets the value of this element.\n"; print $indent . "\t * @return Returns a " . $pre . ucfirst($type) . " of the value.\n"; print $indent . "\t */\n"; //code print $indent . "\t" . $pre . ucfirst($type) . " &getValue() { return _value; }\n"; //comment print $indent . "\t/**\n" . $indent . "\t * Gets the value of this element.\n"; print $indent . "\t * @return Returns a constant " . $pre . ucfirst($type) . " of the value.\n"; print $indent . "\t */\n"; //code print $indent . "\tconst " . $pre . ucfirst($type) . " &getValue() const { return _value; }\n"; //comment print $indent . "\t/**\n" . $indent . "\t * Sets the _value of this element.\n"; print $indent . "\t * @param val The new value for this element.\n"; print $indent . "\t */\n"; //code print $indent . "\tvoid setValue( const " . $pre . ucfirst($type) . " &val ) { _value = val; }\n\n"; //print $indent ."\t _meta->getValueAttribute()->setIsValid(true); }\n\n"; } else { if (strstr($baseStringTypes, $baseType) !== FALSE && count($typemeta[$type]['enum']) == 0) { //comment print $indent . "\t/**\n" . $indent . "\t * Gets the value of this element.\n"; print $indent . "\t * @return Returns a " . $pre . ucfirst($type) . " of the value.\n"; print $indent . "\t */\n"; //code print $indent . "\t" . $pre . ucfirst($type) . " getValue() const { return _value; }\n"; //comment print $indent . "\t/**\n" . $indent . "\t * Sets the _value of this element.\n"; print $indent . "\t * @param val The new value for this element.\n"; print $indent . "\t */\n"; //code print $indent . "\tvoid setValue( " . $pre . ucfirst($type) . " val ) { *(daeStringRef*)&_value = val; }\n\n"; } else { //comment print $indent . "\t/**\n" . $indent . "\t * Gets the value of this element.\n"; print $indent . "\t * @return a " . $pre . ucfirst($type) . " of the value.\n"; print $indent . "\t */\n"; //code print $indent . "\t" . $pre . ucfirst($type) . "& getValue() { return _value; }\n"; //comment print $indent . "\t/**\n" . $indent . "\t * Sets the _value of this element.\n"; print $indent . "\t * @param val The new value for this element.\n"; print $indent . "\t */\n"; //code print $indent . "\tvoid setValue( const " . $pre . ucfirst($type) . "& val ) { _value = val; }\n\n"; //print $indent ."\t _meta->getValueAttribute()->setIsValid(true); }\n\n"; } } } } } } } }
print $indent . "\t" . $pre . ucfirst($type) . " attr" . ucfirst($attr_name) . ";\n"; } } // ELEMENTS if (count($bag['attributes'] > 0)) { print "\n"; } printElements($bag, $needsContents, $indent); printAccessorsAndMutators($bag, $needsContents, $indent); //VALUE // NOTE: special casing any element with 'mixed' content model to ListOfInts type _value if (($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] && !isset($bag['baseTypeViaRestriction'])) { print $indent . "protected: // Value\n"; $content_type = $bag['content_type']; $pre = ''; getTypeNameAndPrefix($content_type, $pre); if ($bag['parent_meta']['inline_elements'] != NULL && array_key_exists($content_type, $bag['parent_meta']['inline_elements'])) { $pre = '::' . $pre; } print $indent . "\t/**\n" . $indent . "\t * The " . $pre . ucfirst($content_type) . " value of the text data of this element. "; print "\n" . $indent . "\t */\n"; $valueType = $pre . ucfirst($content_type); if ($meta[$content_type]['isAComplexType']) { $valueType = $valueType . "Ref"; } print $indent . "\t" . $valueType . " _value;\n"; } //CONSTRUCTORS printConstructors($full_element_name, $bag, $baseClass, $indent); print "\n" . $indent . "public: // STATIC METHODS\n"; print $indent . "\t/**\n" . $indent . "\t * Creates an instance of this class and returns a daeElementRef referencing it.\n";