C++
headers(hpp) with Python style.
linking is a annoying thing, so I write these source code in headers file(*.hpp
), you can use them only with #include "xx.hpp"
, without linking *.a or *.so .
no linking , no hurts
But except for MysqlClient.hpp
, if you #include "MysqlClient.hpp"
, you need linking with -lmysqlclient
.
using namespace limonp;
string strname = "hello, world";
print(strname); //hello, world.
map<string, int> mp;
mp["hello"] = 1;
mp["world"] = 2;
print(mp); // {"hello": 1, "world": 2}
string res;
res << mp;
print(res); // {"hello": 1, "world": 2}
Because of having overrided <<
operator in file src/std_outbound.hpp
, it not only suitable for map but also can be used for vector, set, unordered_map
.
string str;
string_format(str, "%s, %s", "hello", "world");
print(str);
//hello, world.
string str;
char * a[] = {"hello", "world"};
join(a, a + sizeof(a)/sizeof(a[0]), str, ",");
print(str);
//hello, world;
string str = "hello, world";
vector<string> buf;
split(str, buf, ",");
print(buf);
//["hello", "world"];
LogInfo("%s, %s.", "hello", "world");
//2014-04-05 20:52:37 demo.cpp:20 INFO hello, world
In the same way, LogDebug,LogWarn,LogError,LogFatal
.
see details in the code.
md5.hpp
is copied from network, you can find original author in source code(in comments).MutexLock.hpp
,BlockingQueue.hpp
,Condition.hpp
reference from muduo.