Exemplo n.º 1
0
SchemeList::SchemeList(const std::string &expr)
    : m_listString(expr)
{
    eraseWhiteSpaces();

    if (m_listString.empty()/* || m_listString[0] != '(' || m_listString[m_listString.size() - 1] != ')'*/)
        m_listString = "()";
//        throw std::runtime_error("Bad expression.");
}
Exemplo n.º 2
0
void SystemPath::parse( String const& systempathstring )
{
    if( systempathstring.empty() )
    {
        return;
    }

    String aString( systempathstring );
    eraseWhiteSpaces( aString );
    
    String::size_type aCompStart( 0 );
    
    // absolute path ( start with '/' )
    if( aString[ 0 ] == DELIMITER )
    {
        push_back( String( 1, DELIMITER ) );
        ++aCompStart;
    }

    for ( String::size_type aCompEnd; aCompStart < aString.size();
            aCompStart = aCompEnd + 1 )
    {
        aCompEnd = aString.find_first_of( DELIMITER, aCompStart );
        if ( aCompEnd == String::npos )
        {
            aCompEnd = aString.size();
        }

        String aComponent( aString.substr( aCompStart, aCompEnd - aCompStart ) );
        if ( aComponent == ".." )
        {
            if ( theComponents.size() == 1 &&
                    theComponents.front()[ 0 ] == DELIMITER )
            {
                THROW_EXCEPTION( BadSystemPath, 
                                 "Too many levels of retraction with .." );
            }
            else if ( theComponents.empty() || theComponents.back() == ".." )
            {
                theComponents.push_back( aComponent );
            }
            else 
            {
                theComponents.pop_back();
            }
        }
        else if ( !aComponent.empty() && aComponent != "." )
        {
            theComponents.push_back( aComponent );
        }
    }

    if ( !aString.empty() && theComponents.empty() )
    {
        theComponents.push_back( "." );
    }
}
Exemplo n.º 3
0
void FullID::parse( String const& fullidstring )
{
    // empty FullID string is invalid
    if( fullidstring == "" )
    {
        THROW_EXCEPTION( BadID, "empty FullID string" );
    }

    String aString( fullidstring );
    eraseWhiteSpaces( aString );

    // ignore leading white spaces
    String::size_type aFieldStart( 0 );
    String::size_type aFieldEnd( aString.find_first_of( DELIMITER, aFieldStart ) );
    if( aFieldEnd == String::npos )
    {
        THROW_EXCEPTION( BadID, 
                         "no ':' in the FullID string [" + aString + "]" );
    }

    String aTypeString( aString.substr( aFieldStart, aFieldEnd - aFieldStart ) );
    theEntityType = EntityType( aTypeString );
    
    aFieldStart = aFieldEnd + 1;
    aFieldEnd = aString.find_first_of( DELIMITER, aFieldStart );
    if( aFieldEnd == String::npos )
    {
        THROW_EXCEPTION( BadID, "only one ':' in the FullID string [" 
                                + aString + "]" );
    }

    
    theSystemPath = SystemPath( aString.substr( aFieldStart, 
                                aFieldEnd - aFieldStart ) );
    
    aFieldStart = aFieldEnd + 1;

    // drop trailing string after extra ':'(if this is    FullPN),
    // or go to the end
    aFieldEnd = aString.find_first_of( DELIMITER, aFieldStart );

    theID = aString.substr( aFieldStart, aFieldEnd - aFieldStart );
}
Exemplo n.º 4
0
FullPN::FullPN( String const& fullpropertynamestring )
    : theFullID( fullpropertynamestring )
{

    String::size_type aPosition( 0 );

    for( int i( 0 ) ; i < 3 ; ++i )
    {
        aPosition = fullpropertynamestring.
            find_first_of( FullID::DELIMITER, aPosition );
        if( aPosition == String::npos ) 
        {
            THROW_EXCEPTION( BadID, "not enough fields in FullPN string [" +
                                    fullpropertynamestring + "]" );
        }
        ++aPosition;
    }

    thePropertyName = fullpropertynamestring.substr( aPosition, String::npos );
    eraseWhiteSpaces( thePropertyName );
}