ResInsight/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp

77 lines
2.4 KiB
C++
Raw Normal View History

#include "cafFilePath.h"
#include <QTextStream>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2020-06-19 00:53:59 -05:00
caf::FilePath::FilePath()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2020-06-19 00:53:59 -05:00
caf::FilePath::FilePath( const QString& filePath )
: m_filePath( filePath )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString caf::FilePath::path() const
{
return m_filePath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2020-06-19 00:53:59 -05:00
void caf::FilePath::setPath( const QString& filePath )
{
m_filePath = filePath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2020-06-19 00:53:59 -05:00
bool caf::FilePath::operator==( const FilePath& other ) const
{
return m_filePath == other.m_filePath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2020-06-19 00:53:59 -05:00
QTextStream& operator>>( QTextStream& str, caf::FilePath& filePath )
{
QString text;
2020-06-19 00:53:59 -05:00
while ( str.status() == QTextStream::Ok )
{
// Read QChar to avoid white space trimming when reading QString
QChar singleChar;
str >> singleChar;
2020-06-19 00:53:59 -05:00
if ( !singleChar.isNull() )
{
text += singleChar;
}
}
2020-06-19 00:53:59 -05:00
filePath.setPath( text );
return str;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2020-06-19 00:53:59 -05:00
QTextStream& operator<<( QTextStream& str, const caf::FilePath& filePath )
{
str << filePath.path();
return str;
}