Remove remaining non-boost_pp libraries as requirements.
This commit is contained in:
@@ -8,17 +8,15 @@
|
|||||||
|
|
||||||
#include <chaiscript/chaiscript.hpp>
|
#include <chaiscript/chaiscript.hpp>
|
||||||
#include <chaiscript/dispatchkit/function_call.hpp>
|
#include <chaiscript/dispatchkit/function_call.hpp>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
void log(const std::string &msg)
|
void log(const std::string &msg)
|
||||||
{
|
{
|
||||||
std::cout << "[" << boost::posix_time::microsec_clock::local_time() << "] " << msg << std::endl;
|
std::cout << "[" << time(nullptr) << "] " << msg << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(const std::string &module, const std::string &msg)
|
void log(const std::string &module, const std::string &msg)
|
||||||
{
|
{
|
||||||
std::cout << "[" << boost::posix_time::microsec_clock::local_time() << "] <" << module << "> " << msg << std::endl;
|
std::cout << "[" << time(nullptr) << "] <" << module << "> " << msg << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bound_log(const std::string &msg)
|
void bound_log(const std::string &msg)
|
||||||
@@ -140,7 +138,9 @@ int main(int /*argc*/, char * /*argv*/[]) {
|
|||||||
//Creating a functor on the stack and using it immediatly
|
//Creating a functor on the stack and using it immediatly
|
||||||
int x = chai.eval<std::function<int (int, int)> >("fun (x, y) { return x + y; }")(5, 6);
|
int x = chai.eval<std::function<int (int, int)> >("fun (x, y) { return x + y; }")(5, 6);
|
||||||
|
|
||||||
log("Functor test output", boost::lexical_cast<std::string>(x));
|
std::stringstream ss;
|
||||||
|
ss << x;
|
||||||
|
log("Functor test output", ss.str());
|
||||||
|
|
||||||
chai.add(var(std::shared_ptr<int>()), "nullvar");
|
chai.add(var(std::shared_ptr<int>()), "nullvar");
|
||||||
chai("print(\"This should be true.\"); print(nullvar.is_var_null())");
|
chai("print(\"This should be true.\"); print(nullvar.is_var_null())");
|
||||||
|
18
src/main.cpp
18
src/main.cpp
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <regex>
|
||||||
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
#include <chaiscript/chaiscript.hpp>
|
#include <chaiscript/chaiscript.hpp>
|
||||||
@@ -80,7 +80,21 @@ std::string get_next_command() {
|
|||||||
char *input_raw = readline("eval> ");
|
char *input_raw = readline("eval> ");
|
||||||
if ( input_raw ) {
|
if ( input_raw ) {
|
||||||
add_history(input_raw);
|
add_history(input_raw);
|
||||||
retval = boost::trim_copy_if(std::string(input_raw),boost::algorithm::is_any_of(" \t"));
|
|
||||||
|
std::string val(input_raw);
|
||||||
|
size_t pos = val.find_first_not_of("\t \n");
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
val.erase(0, pos);
|
||||||
|
}
|
||||||
|
pos = val.find_last_not_of("\t \n");
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
val.erase(pos+1, std::string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
retval = val;
|
||||||
|
|
||||||
::free(input_raw);
|
::free(input_raw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user