// ExtractIntellisenseOptions //------------------------------------------------------------------------------ /*static*/ void ProjectGeneratorBase::ExtractIntellisenseOptions( const AString & compilerArgs, const char * option, const char * alternateOption, Array< AString > & outOptions, bool escapeQuotes ) { ASSERT( option ); Array< AString > tokens; compilerArgs.Tokenize( tokens ); const size_t optionLen = AString::StrLen( option ); const size_t alternateOptionLen = alternateOption ? AString::StrLen( alternateOption ) : 0; for ( size_t i=0; i<tokens.GetSize(); ++i ) { AString & token = tokens[ i ]; // strip quotes around token, e.g: "-IFolder/Folder" if ( token.BeginsWith( '"' ) && token.EndsWith( '"' ) ) { token.Assign( token.Get() + 1, token.GetEnd() - 1 ); } AStackString<> optionBody; // Handle space between option and payload if ( ( token == option ) || ( token == alternateOption ) ) { // Handle an incomplete token at the end of list if ( i == ( tokens.GetSize() - 1 ) ) { break; } // Use next token optionBody = tokens[ i + 1 ]; } else if ( token.BeginsWith( option ) ) { // use everything after token optionBody.Assign( token.Get() + optionLen ); } else if ( alternateOption && token.BeginsWith( alternateOption ) ) { // use everything after token optionBody.Assign( token.Get() + alternateOptionLen ); } // Strip quotes around body (e.g. -I"Folder/Folder") if ( optionBody.BeginsWith( '"' ) && optionBody.EndsWith( '"' ) ) { optionBody.Trim( 1, 1 ); } // Did we find something? if ( optionBody.IsEmpty() == false ) { if ( escapeQuotes ) { optionBody.Replace( "\"", "\\\"" ); } outOptions.Append( optionBody ); } } }
// ReadObject //------------------------------------------------------------------------------ bool TextReader::ReadObject() { // Type AStackString<> type; if ( !GetToken( type ) ) { Error( "Missing type token" ); return false; } // ID AStackString<> id; if ( !GetToken( id ) ) { Error( "Missing id token" ); return false; } // Name AStackString<> name; if ( !GetToken( name ) ) { Error( "Missing name" ); return false; } // Create Object RefObject * refObj = ReflectionInfo::CreateObject( type ); Object * obj = DynamicCast< Object >( refObj ); ASSERT( obj ); // TODO: handle this gracefully (skip) if ( obj == nullptr ) { Error( "Failed to create object" ); return false; } m_ObjectsToInit.Append( obj ); // set name name.Replace( "\"", "" ); // strip quotes obj->SetName( name ); // add to parent if not root if ( m_DeserializationStack.IsEmpty() == false ) { // get parent container RefObject * topRefObject = (RefObject *)( m_DeserializationStack.Top().m_Base ); Container * parentContainer = DynamicCast< Container >( topRefObject ); ASSERT( parentContainer ); // parent is not a container - impossible! // sanity check child Object * child = DynamicCast< Object >( obj ); ASSERT( child ); // child is not an Object - impossible! // add to parent parentContainer->AddChild( child ); } // Push onto stack StackFrame sf; sf.m_Base = obj; sf.m_Reflection = obj->GetReflectionInfoV(); sf.m_ArrayProperty = nullptr; #ifdef DEBUG sf.m_RefObject = obj; sf.m_Struct = nullptr; #endif m_DeserializationStack.Append( sf ); if ( m_RootObject == nullptr ) { m_RootObject = obj; } return true; }