Skip to content

Instantly share code, notes, and snippets.

//
#ifndef Engine_h
#define Engine_h
// #include <memory>
namespace {
class Engine {
public:
Engine();
#include <string>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/foreach.hpp>
const std::string XML_PATH1 = "./test1.xml";
int main()
{
boost::property_tree::ptree pt1;
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main()
{
std::string s = "Boost Libraries";
boost::regex expr{"\\w+\\s\\w+"};
std::cout << std::boolalpha << boost::regex_match(s, expr) << '\n';
}
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main()
{
std::string s = "Boost Libraries";
boost::regex expr{"(\\w+)\\s(\\w+)"};
boost::smatch what;
if (boost::regex_search(s, what, expr))
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main()
{
std::string s = " Boost Libraries ";
boost::regex expr{"\\s"};
std::string fmt{"_"};
std::cout << boost::regex_replace(s, expr, fmt) << '\n';
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main()
{
std::string s = "Boost Libraries";
boost::regex expr{"(\\w)\\w+"};
boost::regex_token_iterator<std::string::iterator> it{s.begin(), s.end(),
expr, 1};
class BasicSingleton
{
public:
static BasicSingleton& getInstance();
private:
BasicSingleton() {};
BasicSingleton(const BasicSingleton& other);
static BasicSingleton instance;
};
class DynamicSingleton
{
private:
DynamicSingleton() {};
DynamicSingleton(const DynamicSingleton& other);
~DynamicSingleton() {};
static DynamicSingleton* instance;
public:
template < typename T >
class TemplateSingleton
{
public:
static T * GetInstance()
{
if (instance_ == NULL)
{
instance_ = new T;
}
class DynamicSingleton
{
public:
static DynamicSingleton* GetInstance()
{
if (instance_ == NULL)
{
instance_ = new DynamicSingleton();
}
return instance_;