mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
AppFwk : Add support for output of object and field keywords
This commit is contained in:
@@ -34,6 +34,7 @@ ${CEE_CURRENT_LIST_DIR}RicExpressionParser-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuSummaryVectorDescriptionMap-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}FixedWidthDataParser-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigTimeCurveHistoryMerger-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}ListKeywordsForObjectsAndFields-Test.cpp
|
||||
)
|
||||
|
||||
if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES)
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "cafPdmDefaultObjectFactory.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void writeTextToFile(const QString& filePath, const QString& text)
|
||||
{
|
||||
QFile exportFile(filePath);
|
||||
if (exportFile.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QTextStream stream(&exportFile);
|
||||
|
||||
stream << text;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(ListKeywords, ListAllObjectKeywords)
|
||||
{
|
||||
auto instance = caf::PdmDefaultObjectFactory::instance();
|
||||
|
||||
QString textString;
|
||||
QTextStream stream(&textString);
|
||||
|
||||
std::vector<QString> 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);
|
||||
|
||||
std::vector<QString> classKeywords = instance->classKeywords();
|
||||
for (auto keyword : classKeywords)
|
||||
{
|
||||
stream << keyword << "\n";
|
||||
|
||||
caf::PdmObjectHandle* myClass = instance->create(keyword);
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> fields;
|
||||
myClass->fields(fields);
|
||||
|
||||
for (auto f : fields)
|
||||
{
|
||||
stream << " " << f->keyword() << "\n";
|
||||
}
|
||||
|
||||
stream << "\n";
|
||||
|
||||
delete myClass;
|
||||
}
|
||||
|
||||
QString filePath = "c:/temp/ri-fieldKeywords.txt";
|
||||
// writeTextToFile(filePath, textString);
|
||||
}
|
||||
Reference in New Issue
Block a user