Pointer cleanup (#242)
- Made greater use of smart pointers, eliminating many instances of manual memory management - Do not use pointers at all for many non-polymorphic classes - Assorted other code cleanup
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "SubstitutionField.h"
|
||||
|
||||
#include <QTextStream>
|
||||
@@ -42,25 +43,22 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
QString SubstitutionField::evaluate( const merge::Record* record,
|
||||
const Variables* variables ) const
|
||||
QString SubstitutionField::evaluate( const merge::Record& record,
|
||||
const Variables& variables ) const
|
||||
{
|
||||
QString value = mDefaultValue;
|
||||
|
||||
bool haveRecordField = record &&
|
||||
record->contains(mFieldName) &&
|
||||
!record->value(mFieldName).isEmpty();
|
||||
bool haveVariable = variables &&
|
||||
variables->contains(mFieldName) &&
|
||||
!(*variables)[mFieldName].value().isEmpty();
|
||||
bool haveRecordField = record.contains(mFieldName) &&
|
||||
!record.value(mFieldName).isEmpty();
|
||||
bool haveVariable = variables.contains(mFieldName) && !variables[mFieldName].value().isEmpty();
|
||||
|
||||
if ( haveRecordField )
|
||||
{
|
||||
value = record->value(mFieldName);
|
||||
value = record.value(mFieldName);
|
||||
}
|
||||
else if ( haveVariable )
|
||||
{
|
||||
value = (*variables)[mFieldName].value();
|
||||
value = variables[mFieldName].value();
|
||||
}
|
||||
|
||||
if ( !mFormatType.isNull() )
|
||||
|
||||
Reference in New Issue
Block a user