/** * Virtual method that copies the values of an entry to the given \p variable. * * @param parent The plug-in we belong to. * @param variable The variable to fill with our values. */ public virtual void ToVariable( InMemoryPlugin parent, Variable variable ) { ALIB.ASSERT( Delim != '\0' || Values.Count <= 1); if ( Delim != '\0' ) variable.Delim= Delim; if ( FormatHints != 0 ) variable.FormatHints= FormatHints; if ( FormatAttrAlignment != null ) variable.FormatAttrAlignment= FormatAttrAlignment; variable.Comments._()._( Comments ); foreach( AString val in Values ) variable.AddString( val ); }
/** * Virtual method that copies the values of the given \p variable to us. * * @param parent The plug-in we belong to. * @param variable The variable to fill with our values. */ public virtual void FromVariable( InMemoryPlugin parent, Variable variable ) { // copy attributes Delim= variable.Delim; FormatHints= variable.FormatHints; FormatAttrAlignment= variable.FormatAttrAlignment; if ( Comments.IsEmpty() ) // do not overwrite comments Comments._( variable.Comments ); // adjust size of value array int varSize= variable.Size(); int valSize= Values.Count; while (valSize < varSize ) { Values.Add( new AString() ); valSize++; } while (valSize > varSize ) Values.RemoveAt( --valSize ); // copy for ( int i= 0; i< variable.Size(); i++ ) Values[i]._()._( variable.GetString(i) ); }
/** * Overrides default method. Clears the raw value, and calls base method. * * @param parent The plug-in we belong to. * @param variable The variable to fill with our values. */ public override void FromVariable( InMemoryPlugin parent, Variable variable ) { RawValue._(); base.FromVariable( parent, variable ); }
/** * Overrides default method. If we have not parsed the INI file text value, yet, * we do this now. * * @param parent The plug-in we belong to. * @param variable The variable to fill with our values. */ public override void ToVariable( InMemoryPlugin parent, Variable variable ) { // if we are still raw, then parse the INI file content if ( Values.Count == 0 ) { ALIB.ASSERT( Delim == '\0' ); Delim= variable.Delim; variable.Comments._()._( Comments ); //----- remove INI-File specific from raw value ----- AString raw= new AString(); raw._( RawValue ); // remove '=' raw.TrimStart(); if ( raw.CharAtStart() != '=' ) { ALIB.WARNING( "No equal sign in variable \"" + variable.Fullname + "\" of INI file." ); } else raw.DeleteStart(1).TrimStart(); // remove "\\n" int startIdx= 0; while ( (startIdx= raw.IndexOf( '\n', startIdx )) >= 0 ) { // find \\n and trim around this location int delLen= 2; if ( raw.CharAt( --startIdx) == '\r' ) { delLen= 3; --startIdx; } ALIB.ASSERT( raw.CharAt(startIdx) == '\\' ); raw.Delete( startIdx, delLen ); startIdx= raw.TrimAt( startIdx ); // if now the next value is starting with a comment symbol, we remove to the next \n for(;;) { char c= raw.CharAt( startIdx ); if ( c != '#' && c != ';' && ( c != '/' || raw.CharAt( startIdx + 1 ) != '/' ) ) break; int idx= raw.IndexOf( '\n' ); if (idx < 0 ) idx= raw.Length(); raw.Delete( startIdx, idx - startIdx + 1 ); if( startIdx >= raw.Length() ) break; startIdx= raw.TrimAt( startIdx ); } } // now convert parent.StringConverter.LoadFromString( variable, raw ); // copy the parsed values back to our entry and store the delimiter for( int i= 0; i < variable.Size() ; i++ ) Values.Add( new AString( variable.GetString( i ) ) ); } // otherwise, use base method else base.ToVariable( parent, variable ); }