#include "gtest/gtest.h" #include "RiaVersionInfo.h" #include "cafClassTypeName.h" #include "cafPdmDefaultObjectFactory.h" #include "cafPdmObjectHandle.h" #include #include #include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void writeTextToFile( const QString& filePath, const QString& text ) { QFile exportFile( filePath ); if ( exportFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) { QTextStream stream( &exportFile ); stream << text; } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString versionHeaderText() { QString text; text += QString( "// ResInsight version string : %1\n" ).arg( STRPRODUCTVER ); text += QString( "// Report generated : %1\n" ).arg( QDateTime::currentDateTime().toString() ); text += "//\n"; text += "//\n"; text += "\n"; return text; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST( ListKeywords, ListAllObjectKeywords ) { auto instance = caf::PdmDefaultObjectFactory::instance(); QString textString; QTextStream stream( &textString ); textString = versionHeaderText(); std::vector classKeywords = instance->classKeywords(); for ( auto keyword : classKeywords ) { stream << keyword << "\n"; } QString filePath = "c:/temp/ri-objectKeywords.txt"; // writeTextToFile(filePath, textString); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST( ListKeywords, ListAllObjectKeywordsAndFieldKeywords ) { auto instance = caf::PdmDefaultObjectFactory::instance(); QString textString; QTextStream stream( &textString ); bool includeClassName = true; textString = versionHeaderText(); std::vector classKeywords = instance->classKeywords(); for ( auto keyword : classKeywords ) { caf::PdmObjectHandle* myClass = instance->create( keyword ); stream << keyword; if ( includeClassName ) { QString className = qStringTypeName( *myClass ); stream << " - " << className; } stream << "\n"; std::vector fields = myClass->fields(); for ( auto f : fields ) { stream << " " << f->keyword() << "\n"; } stream << "\n"; delete myClass; } QString filePath = "c:/temp/ri-fieldKeywords.txt"; // writeTextToFile(filePath, textString); }