Skip to content

Commit

Permalink
Fix NthGroup bug and add NthItem family of expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
LB-- committed Dec 7, 2015
1 parent 8f2405f commit 7ec2d00
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
48 changes: 41 additions & 7 deletions Expressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7ec2d00

Please sign in to comment.