From 7ec2d00d9549f3e07ebdddaef168b30daca28149 Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Sun, 6 Dec 2015 19:25:21 -0600 Subject: [PATCH] Fix NthGroup bug and add NthItem family of expressions --- Expressions.cpp | 48 +++++++++++++++++++++++++++++++++++++++++------- Properties.cpp | 4 ++-- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Expressions.cpp b/Expressions.cpp index cabb485..bb3c7c8 100644 --- a/Expressions.cpp +++ b/Expressions.cpp @@ -101,7 +101,7 @@ int Extension::expressionGetY(TCHAR const *group, TCHAR const *item) TCHAR const *Extension::expressionNthGroup(int n) { - if(n > 0 && n < data->ini.size()) + if(n >= 0 && n < data->ini.size()) { auto it = data->ini.begin(); std::advance(it, n); @@ -112,19 +112,46 @@ TCHAR const *Extension::expressionNthGroup(int n) TCHAR const *Extension::expressionNthItem(TCHAR const *group, int n) { - // + if(hasGroup(group)) + { + auto g = groupByName(group); + if(n >= 0 && n < g.size()) + { + auto it = g.begin(); + std::advance(it, n); + return Runtime.CopyString(it->first.c_str()); + } + } return _T(""); } TCHAR const *Extension::expressionNthItemString(TCHAR const *group, int n) { - // + if(hasGroup(group)) + { + auto g = groupByName(group); + if(n >= 0 && n < g.size()) + { + auto it = g.begin(); + std::advance(it, n); + return Runtime.CopyString(it->second.c_str()); + } + } return _T(""); } float Extension::expressionNthItemValue(TCHAR const *group, int n) //TODO { - // + if(hasGroup(group)) + { + auto g = groupByName(group); + if(n >= 0 && n < g.size()) + { + auto it = g.begin(); + std::advance(it, n); + return expressionGetItemValue(group, it->first.c_str(), 0.0f); + } + } return 0.0f; } @@ -135,14 +162,21 @@ int Extension::expressionGroupCount() int Extension::expressionItemCount(TCHAR const *group) { - // + if(hasGroup(group)) + { + return groupByName(group).size(); + } return 0; } int Extension::expressionTotalItems() { - // - return 0; + std::size_t n = 0; + for(auto const &group : data->ini) + { + n += group.second.size(); + } + return n; } int Extension::expressionSearchResultCounts() diff --git a/Properties.cpp b/Properties.cpp index 00703a1..5557b68 100644 --- a/Properties.cpp +++ b/Properties.cpp @@ -239,9 +239,9 @@ void *MMF2Func GetPropValue(mv *mV, SerializedED *SED, UINT PropID) case Prop::Version: { #ifdef UNICODE - return new CPropStringValue(_T("Unicode v1.6 August 2015")); + return new CPropStringValue(_T("Unicode v1.6 December 2015 (v0.2.0-chrilley)")); #else - return new CPropStringValue(_T("ANSI v1.6 August 2015")); + return new CPropStringValue(_T("ANSI v1.6 December 2015 (v0.2.0-chrilley)")); #endif } case Prop::DefPath: