bool FileNode::SetValue(const FileAttributeType eType, const std::wstring strValue) { if (doesAttributeExist(eType)) { m_mapAttributes.at(eType).m_strValue = strValue; return true; } else { if (shouldAddAttribute(eType)) { m_mapAttributes.insert(std::pair<FileAttributeType, AttrValue>(eType, AttrValue(strValue))); return true; } } return false; }
void XMLElement :: DumpOn( std::ostream & os, bool recurse ) const { os << "<" << Name(); for ( unsigned int i = 0; i < AttrCount(); i++ ) { os << " " << AttrName(i) << "=\""; os << AttrValue( AttrName(i) ) << "\""; } if ( ! recurse ) { os << "/>\n"; } else { os << ">\n"; for ( unsigned int i = 0; i < ChildCount(); i++ ) { const XMLElement * ce = ChildElement( i ) ; if ( ce ) { ce->DumpOn( os, recurse ); } const XMLText * ct = ChildText( i ); if ( ct ) { os << LTrim( ct->Text() ) << "\n"; } } os << "</" << Name() << ">\n"; } }
// --------------------------------------------------------- // TCodParser::AttrLineL() // --------------------------------------------------------- // TBool TCodParser::AttrLineL(CMediaObjectData *& aMediaObject) { SkipWhiteSpace(); // Skip lines which contain only WS and LF at the end. while ( IsEndOfLine() ) { NextLine(); SkipWhiteSpace(); } TBool ok( ETrue ); if ( iCurP < iEndP ) { // Still has something to read. switch( AttrName() ) { case ECodName: { if ( Colon() ) { ok = aMediaObject->SetNameL( AttrValue() ); EndOfLine(); } break; } case ECodVendor: { if ( Colon() ) { ok = iData->SetVendorL( AttrValue() ); EndOfLine(); } break; } case ECodDescription: { if ( Colon() ) { ok = aMediaObject->SetDescriptionL( AttrValue() ); EndOfLine(); } break; } case ECodSize: { if ( Colon() ) { // Parse as TUint - negative not allowed. TUint size; TLex lex( AttrValue() ); if ( !lex.Val( size ) ) { aMediaObject->SetSize( size ); } else { ok = EFalse; } EndOfLine(); } break; } case ECodInstallNotify: { if ( Colon() ) { ok = aMediaObject->SetInstallNotifyL( AttrValue() ); EndOfLine(); } break; } case ECodNextUrl: { if ( Colon() ) { ok = iData->SetNextUrlL( AttrValue() ); EndOfLine(); } break; } case ECodNextUrlAtError: { if ( Colon() ) { ok = iData->SetNextUrlAtErrorL( AttrValue() ); EndOfLine(); } break; } case ECodInfoUrl: { if ( Colon() ) { ok = aMediaObject->SetInfoUrlL( AttrValue() ); EndOfLine(); } break; } case ECodPrice: { if ( Colon() ) { ok = aMediaObject->SetPriceL( AttrValue() ); EndOfLine(); } break; } case ECodIcon: { if ( Colon() ) { ok = aMediaObject->SetIconL( AttrValue() ); EndOfLine(); } break; } case ECodType: { if ( Colon() ) { ok = aMediaObject->SetTypeL( AttrValue() ); EndOfLine(); } break; } case ECodUrl: { if ( Colon() ) { ok = aMediaObject->SetUrlL( AttrValue() ); EndOfLine(); } break; } case ECodUnknownAttr: { // Name unknown; check colon anyway (syntax check). ok = Colon(); // Rest of the line goes unchecked. break; } default: { // Unexpected value. CodPanic( ECodInternal ); } } if ( !ok ) { Error( KErrCodInvalidDescriptor ); } NextLine(); // Step past LF. return ETrue; // More lines to go. } else { // EOF reached; done. // Note: not expecting EOF in any other place than here (well-formed // COD has complete attrlines. If EOF is found some other place, it // is a syntax error. return EFalse; } }