Ejemplo n.º 1
0
TInt CFsObjectCon::CheckUniqueName(const CFsObject* anObject) const
//
// Returns KErrBadName if the name is invalid or
// returns KErrAlreadyExists if the full name is not unique.
//
	{

	TName name(*(anObject->iName));
	TInt r=validateName(name);
	if (r!=KErrNone)
		return r;

	if (!iCount)
		return KErrNone;

	CFsObject** pS=iObjects;
	CFsObject** pE=pS+iCount;

	// if it's name is null, just need to check it's not already there
	if (!anObject->iName)
		{
		do
			{
			if (*pS==anObject)
				return KErrAlreadyExists;
			} while(++pS<pE);
		return KErrNone;
		}

	do
		{
		if (NamesMatch(name,*pS))
			return KErrAlreadyExists;
		} while(++pS<pE);
	return KErrNone;
	}
Ejemplo n.º 2
0
void cParseNamedAttr::Validate() const
{
    if( NamesMatch( twparser::STR_PARSER_RULENAME, mstrName ) )
    {
        // no checking needed
    }
    else if( NamesMatch( twparser::STR_PARSER_EMAILTO, mstrName ) )
    {
        // no checking needed
    }
    else if( NamesMatch( twparser::STR_PARSER_SEVERITY, mstrName ) )
    {
        int iIgnore;
        cSeverityLimits sl;
        if( ! sl.InterpretInt( mstrValue, &iIgnore ) )
            throw eParserBadSevVal( mstrValue, mLineNum );
    }
    else if( NamesMatch( twparser::STR_PARSER_RECURSE, mstrName ) )
    {
        TSTRING str = mstrValue;
        std::transform( str.begin(), str.end(), str.begin(), _totlower );
    
        if( !NamesMatch( twparser::STR_PARSER_FALSE, str ) && !NamesMatch( twparser::STR_PARSER_TRUE, str ) )
        {
            // must be number
            int iIgnore;
            cRecurseDepthLimits rdl;
            if( ! rdl.InterpretInt( str, &iIgnore ) )
                throw eParserUnrecognizedAttrVal( mstrValue, mLineNum );                
        }
    }
    else
    {
        throw eParserUnrecognizedAttr( mstrName, mLineNum );
    }
}