Skip to content

Commit ec49cca

Browse files
committed
Issue #39: Converted internal functions
1 parent 7323e94 commit ec49cca

16 files changed

+177
-166
lines changed

include/shellanything/Validator.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ namespace shellanything
9494
/// </summary>
9595
void SetFileExists(const std::string & iFileExists);
9696

97+
/// <summary>
98+
/// Validate the given context against a set of constraints.
99+
/// The possible constraints includes a minimum/maximum number of files/directories selected,
100+
/// a list of properties that must be defined,
101+
/// a list of file extensions,
102+
/// ...
103+
/// Note: this function is used to enable or disable a menu.
104+
/// </summary>
97105
bool Validate(const Context & iContext) const;
98106

99107
private:

src/GlogUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,5 @@ namespace shellanything
320320
//https://codeyarns.com/2017/10/26/how-to-install-and-use-glog/
321321
google::InitGoogleLogging(g_argv[0]);
322322
}
323+
323324
} //namespace shellanything

src/InputBox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
static const wchar_t * INPUTBOX_CLASS_NAME = L"InputBox";
3939

40-
HFONT createInputBoxFont()
40+
HFONT CreateInputBoxFont()
4141
{
4242
//https://stackoverflow.com/questions/221411/how-can-i-specify-a-font-for-a-window-created-through-createwindow
4343

src/ObjectFactory.cpp

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace shellanything
7070
}
7171

7272
typedef std::vector<const XMLElement *> ElementPtrList;
73-
ElementPtrList getChildNodes(const XMLElement* element, const std::string & name)
73+
ElementPtrList GetChildNodes(const XMLElement* element, const std::string & name)
7474
{
7575
ElementPtrList elements;
7676

@@ -90,7 +90,7 @@ namespace shellanything
9090
return elements;
9191
}
9292

93-
bool parseAttribute(const XMLElement* element, const char * attr_name, bool is_optional, bool allow_empty_values, std::string & attr_value, std::string & error)
93+
bool ParseAttribute(const XMLElement* element, const char * attr_name, bool is_optional, bool allow_empty_values, std::string & attr_value, std::string & error)
9494
{
9595
if (element == NULL)
9696
{
@@ -123,10 +123,10 @@ namespace shellanything
123123
return true;
124124
}
125125

126-
bool parseAttribute(const XMLElement* element, const char * attr_name, bool is_optional, bool allow_empty_values, int & attr_value, std::string & error)
126+
bool ParseAttribute(const XMLElement* element, const char * attr_name, bool is_optional, bool allow_empty_values, int & attr_value, std::string & error)
127127
{
128128
std::string str_value;
129-
if (!parseAttribute(element, attr_name, is_optional, allow_empty_values, str_value, error))
129+
if (!ParseAttribute(element, attr_name, is_optional, allow_empty_values, str_value, error))
130130
return false; //error is already set
131131

132132
//convert string to int
@@ -161,21 +161,21 @@ namespace shellanything
161161

162162
//parse maxfiles
163163
int maxfiles = -1;
164-
if (parseAttribute(element, "maxfiles", true, true, maxfiles, error))
164+
if (ParseAttribute(element, "maxfiles", true, true, maxfiles, error))
165165
{
166166
result.SetMaxFiles(maxfiles);
167167
}
168168

169169
//parse maxfolders
170170
int maxfolders = -1;
171-
if (parseAttribute(element, "maxfolders", true, true, maxfolders, error))
171+
if (ParseAttribute(element, "maxfolders", true, true, maxfolders, error))
172172
{
173173
result.SetMaxDirectories(maxfolders);
174174
}
175175

176176
//parse fileextensions
177177
std::string fileextensions;
178-
if (parseAttribute(element, "fileextensions", true, true, fileextensions, error))
178+
if (ParseAttribute(element, "fileextensions", true, true, fileextensions, error))
179179
{
180180
if (!fileextensions.empty())
181181
{
@@ -185,7 +185,7 @@ namespace shellanything
185185

186186
//parse exists
187187
std::string exists;
188-
if (parseAttribute(element, "exists", true, true, exists, error))
188+
if (ParseAttribute(element, "exists", true, true, exists, error))
189189
{
190190
if (!exists.empty())
191191
{
@@ -195,7 +195,7 @@ namespace shellanything
195195

196196
//parse properties
197197
std::string properties;
198-
if (parseAttribute(element, "properties", true, true, properties, error))
198+
if (ParseAttribute(element, "properties", true, true, properties, error))
199199
{
200200
if (!properties.empty())
201201
{
@@ -227,7 +227,7 @@ namespace shellanything
227227
//parse value
228228
tmp_str = "";
229229
tmp_int = -1;
230-
if (parseAttribute(element, "value", false, true, tmp_str, error))
230+
if (ParseAttribute(element, "value", false, true, tmp_str, error))
231231
{
232232
action->SetValue(tmp_str);
233233
}
@@ -242,23 +242,23 @@ namespace shellanything
242242
//parse path
243243
tmp_str = "";
244244
tmp_int = -1;
245-
if (parseAttribute(element, "path", false, true, tmp_str, error))
245+
if (ParseAttribute(element, "path", false, true, tmp_str, error))
246246
{
247247
action->SetPath(tmp_str);
248248
}
249249

250250
//parse arguments
251251
tmp_str = "";
252252
tmp_int = -1;
253-
if (parseAttribute(element, "arguments", true, true, tmp_str, error))
253+
if (ParseAttribute(element, "arguments", true, true, tmp_str, error))
254254
{
255255
action->SetArguments(tmp_str);
256256
}
257257

258258
//parse basedir
259259
tmp_str = "";
260260
tmp_int = -1;
261-
if (parseAttribute(element, "basedir", true, true, tmp_str, error))
261+
if (ParseAttribute(element, "basedir", true, true, tmp_str, error))
262262
{
263263
action->SetBaseDir(tmp_str);
264264
}
@@ -273,7 +273,7 @@ namespace shellanything
273273
//parse path
274274
tmp_str = "";
275275
tmp_int = -1;
276-
if (parseAttribute(element, "path", false, true, tmp_str, error))
276+
if (ParseAttribute(element, "path", false, true, tmp_str, error))
277277
{
278278
action->SetPath(tmp_str);
279279
}
@@ -288,7 +288,7 @@ namespace shellanything
288288
//parse encoding
289289
tmp_str = "";
290290
tmp_int = -1;
291-
if (parseAttribute(element, "encoding", true, true, tmp_str, error))
291+
if (ParseAttribute(element, "encoding", true, true, tmp_str, error))
292292
{
293293
action->SetEncoding(tmp_str);
294294
}
@@ -303,47 +303,47 @@ namespace shellanything
303303
//parse name
304304
tmp_str = "";
305305
tmp_int = -1;
306-
if (parseAttribute(element, "name", false, true, tmp_str, error))
306+
if (ParseAttribute(element, "name", false, true, tmp_str, error))
307307
{
308308
action->SetName(tmp_str);
309309
}
310310

311311
//parse title
312312
tmp_str = "";
313313
tmp_int = -1;
314-
if (parseAttribute(element, "title", false, true, tmp_str, error))
314+
if (ParseAttribute(element, "title", false, true, tmp_str, error))
315315
{
316316
action->SetTitle(tmp_str);
317317
}
318318

319319
//parse default
320320
tmp_str = "";
321321
tmp_int = -1;
322-
if (parseAttribute(element, "default", true, true, tmp_str, error))
322+
if (ParseAttribute(element, "default", true, true, tmp_str, error))
323323
{
324324
action->SetDefault(tmp_str);
325325
}
326326

327327
//parse type
328328
tmp_str = "";
329329
tmp_int = -1;
330-
if (parseAttribute(element, "type", true, true, tmp_str, error))
330+
if (ParseAttribute(element, "type", true, true, tmp_str, error))
331331
{
332332
action->SetType(tmp_str);
333333
}
334334

335335
//parse valueyes
336336
tmp_str = "";
337337
tmp_int = -1;
338-
if (parseAttribute(element, "valueyes", true, true, tmp_str, error))
338+
if (ParseAttribute(element, "valueyes", true, true, tmp_str, error))
339339
{
340340
action->SetValueYes(tmp_str);
341341
}
342342

343343
//parse valueno
344344
tmp_str = "";
345345
tmp_int = -1;
346-
if (parseAttribute(element, "valueno", true, true, tmp_str, error))
346+
if (ParseAttribute(element, "valueno", true, true, tmp_str, error))
347347
{
348348
action->SetValueNo(tmp_str);
349349
}
@@ -358,15 +358,15 @@ namespace shellanything
358358
//parse name
359359
tmp_str = "";
360360
tmp_int = -1;
361-
if (parseAttribute(element, "name", false, true, tmp_str, error))
361+
if (ParseAttribute(element, "name", false, true, tmp_str, error))
362362
{
363363
action->SetName(tmp_str);
364364
}
365365

366366
//parse value
367367
tmp_str = "";
368368
tmp_int = -1;
369-
if (parseAttribute(element, "value", false, true, tmp_str, error))
369+
if (ParseAttribute(element, "value", false, true, tmp_str, error))
370370
{
371371
action->SetValue(tmp_str);
372372
}
@@ -381,7 +381,7 @@ namespace shellanything
381381
//parse path
382382
tmp_str = "";
383383
tmp_int = -1;
384-
if (parseAttribute(element, "path", false, true, tmp_str, error))
384+
if (ParseAttribute(element, "path", false, true, tmp_str, error))
385385
{
386386
action->SetPath(tmp_str);
387387
}
@@ -396,23 +396,23 @@ namespace shellanything
396396
//parse title
397397
tmp_str = "";
398398
tmp_int = -1;
399-
if (parseAttribute(element, "title", false, true, tmp_str, error))
399+
if (ParseAttribute(element, "title", false, true, tmp_str, error))
400400
{
401401
action->SetTitle(tmp_str);
402402
}
403403

404404
//parse caption
405405
tmp_str = "";
406406
tmp_int = -1;
407-
if (parseAttribute(element, "caption", false, true, tmp_str, error))
407+
if (ParseAttribute(element, "caption", false, true, tmp_str, error))
408408
{
409409
action->SetCaption(tmp_str);
410410
}
411411

412412
//parse icon
413413
tmp_str = "";
414414
tmp_int = -1;
415-
if (parseAttribute(element, "icon", true, true, tmp_str, error))
415+
if (ParseAttribute(element, "icon", true, true, tmp_str, error))
416416
{
417417
action->SetIcon(tmp_str);
418418
}
@@ -450,7 +450,7 @@ namespace shellanything
450450

451451
//parse separator
452452
std::string menu_separator;
453-
bool have_separetor = parseAttribute(element, "separator", true, true, menu_separator, error);
453+
bool have_separetor = ParseAttribute(element, "separator", true, true, menu_separator, error);
454454
bool is_separator = false;
455455
if (have_separetor)
456456
{
@@ -464,7 +464,7 @@ namespace shellanything
464464

465465
//parse name
466466
std::string menu_name;
467-
if (!parseAttribute(element, "name", false, false, menu_name, error))
467+
if (!ParseAttribute(element, "name", false, false, menu_name, error))
468468
{
469469
delete menu;
470470
return NULL;
@@ -473,14 +473,14 @@ namespace shellanything
473473

474474
//parse description
475475
std::string menu_desc;
476-
if (!parseAttribute(element, "description", true, true, menu_desc, error))
476+
if (!ParseAttribute(element, "description", true, true, menu_desc, error))
477477
{
478478
menu->SetDescription(menu_desc);
479479
}
480480

481481
//parse icon
482482
std::string icon_path;
483-
if (parseAttribute(element, "icon", true, true, icon_path, error))
483+
if (ParseAttribute(element, "icon", true, true, icon_path, error))
484484
{
485485
Icon icon;
486486
icon.SetPath(icon_path);
@@ -490,7 +490,7 @@ namespace shellanything
490490
ElementPtrList elements; //temporary xml element containers
491491

492492
//find <validity> node under <menu>
493-
elements = getChildNodes(element, NODE_VALIDITY);
493+
elements = GetChildNodes(element, NODE_VALIDITY);
494494
for(size_t i=0; i<elements.size(); i++)
495495
{
496496
Validator validity;
@@ -503,7 +503,7 @@ namespace shellanything
503503
}
504504

505505
//find <visibility> node under <menu>
506-
elements = getChildNodes(element, NODE_VISIBILITY);
506+
elements = GetChildNodes(element, NODE_VISIBILITY);
507507
for(size_t i=0; i<elements.size(); i++)
508508
{
509509
Validator visibility;
@@ -542,7 +542,7 @@ namespace shellanything
542542
}
543543

544544
//find <menu> node under <menu>
545-
elements = getChildNodes(element, NODE_MENU);
545+
elements = GetChildNodes(element, NODE_MENU);
546546
for(size_t i=0; i<elements.size(); i++)
547547
{
548548
Menu * submenu = ObjectFactory::GetInstance().ParseMenu(elements[i], error);
@@ -555,7 +555,7 @@ namespace shellanything
555555
}
556556

557557
//find <icon> node under <menu>
558-
elements = getChildNodes(element, "icon");
558+
elements = GetChildNodes(element, "icon");
559559
for(size_t i=0; i<elements.size(); i++)
560560
{
561561
Icon icon;
@@ -588,11 +588,11 @@ namespace shellanything
588588

589589
//parse path
590590
std::string icon_path;
591-
bool hasPath = parseAttribute(element, "path", true, true, icon_path, error);
591+
bool hasPath = ParseAttribute(element, "path", true, true, icon_path, error);
592592

593593
//parse fileextension
594594
std::string icon_fileextension;
595-
bool hasFileExtension = parseAttribute(element, "fileextension", true, true, icon_fileextension, error);
595+
bool hasFileExtension = ParseAttribute(element, "fileextension", true, true, icon_fileextension, error);
596596

597597
if (!hasPath && !hasFileExtension)
598598
{
@@ -608,7 +608,7 @@ namespace shellanything
608608

609609
//parse index
610610
int icon_index = -1;
611-
if (parseAttribute(element, "index", true, true, icon_index, error))
611+
if (ParseAttribute(element, "index", true, true, icon_index, error))
612612
{
613613
result.SetIndex(icon_index);
614614
}
@@ -638,7 +638,7 @@ namespace shellanything
638638
ElementPtrList elements; //temporary xml element containers
639639

640640
//find <property> node under <default>
641-
elements = getChildNodes(element, NODE_ACTION_PROPERTY);
641+
elements = GetChildNodes(element, NODE_ACTION_PROPERTY);
642642
for(size_t i=0; i<elements.size(); i++)
643643
{
644644
const tinyxml2::XMLElement * element = elements[i];

0 commit comments

Comments
 (0)