Skip to content

Commit 30021a2

Browse files
authored
Merge pull request #9 from RobLoach/master
String Methods: Move declaration of vector of strings
2 parents f1adc0f + 0809390 commit 30021a2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

include/chaiscript/extras/string_methods.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
* string::split(string token)
1010
* string::toLowerCase()
1111
* string::toUpperCase()
12+
*
13+
* To allow selecting indexes from split(), ensure VectorString type is added:
14+
*
15+
* chai.add(chaiscript::bootstrap::standard_library::vector_type<std::vector<std::string>>("VectorString"));
1216
*/
1317
#include <algorithm>
1418
#include <string>
@@ -21,9 +25,6 @@ namespace chaiscript {
2125
namespace string_methods {
2226
ModulePtr bootstrap(ModulePtr m = std::make_shared<Module>())
2327
{
24-
// Add lists of strings.
25-
m->add(bootstrap::standard_library::vector_type<std::vector<std::string>>("StringVector"));
26-
2728
// string::replace(std::string search, std::string replace)
2829
m->add(fun([](const std::string& subject, const std::string& search, const std::string& replace) {
2930
std::string result(subject);

tests/string_methods.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ TEST_CASE( "string_methods functions work", "[string_methods]" ) {
1212

1313
// Add the string_methods module.
1414
auto stringmethods = chaiscript::extras::string_methods::bootstrap();
15+
chai.add(chaiscript::bootstrap::standard_library::vector_type<std::vector<std::string>>("StringVector"));
1516
chai.add(stringmethods);
1617

1718
// replace(string, string)
@@ -31,4 +32,4 @@ TEST_CASE( "string_methods functions work", "[string_methods]" ) {
3132

3233
// toUpperCase()
3334
CHECK(chai.eval<std::string>("\"Hello World!\".toUpperCase()") == "HELLO WORLD!");
34-
}
35+
}

0 commit comments

Comments
 (0)