Skip to content

Commit 7ec2d00

Browse files
committed
Fix NthGroup bug and add NthItem family of expressions
1 parent 8f2405f commit 7ec2d00

2 files changed

Lines changed: 43 additions & 9 deletions

File tree

Expressions.cpp

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int Extension::expressionGetY(TCHAR const *group, TCHAR const *item)
101101

102102
TCHAR const *Extension::expressionNthGroup(int n)
103103
{
104-
if(n > 0 && n < data->ini.size())
104+
if(n >= 0 && n < data->ini.size())
105105
{
106106
auto it = data->ini.begin();
107107
std::advance(it, n);
@@ -112,19 +112,46 @@ TCHAR const *Extension::expressionNthGroup(int n)
112112

113113
TCHAR const *Extension::expressionNthItem(TCHAR const *group, int n)
114114
{
115-
//
115+
if(hasGroup(group))
116+
{
117+
auto g = groupByName(group);
118+
if(n >= 0 && n < g.size())
119+
{
120+
auto it = g.begin();
121+
std::advance(it, n);
122+
return Runtime.CopyString(it->first.c_str());
123+
}
124+
}
116125
return _T("");
117126
}
118127

119128
TCHAR const *Extension::expressionNthItemString(TCHAR const *group, int n)
120129
{
121-
//
130+
if(hasGroup(group))
131+
{
132+
auto g = groupByName(group);
133+
if(n >= 0 && n < g.size())
134+
{
135+
auto it = g.begin();
136+
std::advance(it, n);
137+
return Runtime.CopyString(it->second.c_str());
138+
}
139+
}
122140
return _T("");
123141
}
124142

125143
float Extension::expressionNthItemValue(TCHAR const *group, int n) //TODO
126144
{
127-
//
145+
if(hasGroup(group))
146+
{
147+
auto g = groupByName(group);
148+
if(n >= 0 && n < g.size())
149+
{
150+
auto it = g.begin();
151+
std::advance(it, n);
152+
return expressionGetItemValue(group, it->first.c_str(), 0.0f);
153+
}
154+
}
128155
return 0.0f;
129156
}
130157

@@ -135,14 +162,21 @@ int Extension::expressionGroupCount()
135162

136163
int Extension::expressionItemCount(TCHAR const *group)
137164
{
138-
//
165+
if(hasGroup(group))
166+
{
167+
return groupByName(group).size();
168+
}
139169
return 0;
140170
}
141171

142172
int Extension::expressionTotalItems()
143173
{
144-
//
145-
return 0;
174+
std::size_t n = 0;
175+
for(auto const &group : data->ini)
176+
{
177+
n += group.second.size();
178+
}
179+
return n;
146180
}
147181

148182
int Extension::expressionSearchResultCounts()

Properties.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ void *MMF2Func GetPropValue(mv *mV, SerializedED *SED, UINT PropID)
239239
case Prop::Version:
240240
{
241241
#ifdef UNICODE
242-
return new CPropStringValue(_T("Unicode v1.6 August 2015"));
242+
return new CPropStringValue(_T("Unicode v1.6 December 2015 (v0.2.0-chrilley)"));
243243
#else
244-
return new CPropStringValue(_T("ANSI v1.6 August 2015"));
244+
return new CPropStringValue(_T("ANSI v1.6 December 2015 (v0.2.0-chrilley)"));
245245
#endif
246246
}
247247
case Prop::DefPath:

0 commit comments

Comments
 (0)