Added option to compile with google btree instead of map

This commit is contained in:
= 2015-07-14 17:41:07 -07:00
parent 39bcdbbdc8
commit 7be48f5117
4 changed files with 29 additions and 21 deletions

View File

@ -15,7 +15,7 @@ AM_CPPFLAGSINVALID = -DPC_REMOVE_INVALID
endif endif
if BUILD_WITH_BTREE if BUILD_WITH_BTREE
AM_CPPFLAGSBTREE = -DBUILD_WITH_BTREE AM_CPPFLAGSBTREE = -DBUILD_WITH_BTREE -std=c++11
endif endif
AM_CPPFLAGS = $(AM_CPPFLAGSBTREE) $(AM_CPPFLAGSINVALID) AM_CPPFLAGS = $(AM_CPPFLAGSBTREE) $(AM_CPPFLAGSINVALID)

View File

@ -91,26 +91,33 @@ if test "x$enable_btree" == "xyes"; then
AC_CHECK_TOOL([MERCURIAL], [hg], [no]) AC_CHECK_TOOL([MERCURIAL], [hg], [no])
AM_CONDITIONAL([HAVE_HG_BIN], [test "x${MERCURIAL}" = "xhg"])
if test "x${MERCURIAL}" = "xhg"; then
have_hg_bin=1
fi
AC_MSG_CHECKING([for ${srcdir}/cpp-btree/btree_map.h])
AC_MSG_CHECKING([for ${srcdir}/cpp-btree/btree.h]) if test -f ${srcdir}/cpp-btree/btree_map.h; then
have_btree_h=1
AC_MSG_RESULT([found.])
else
AC_MSG_RESULT([no])
fi
AM_CONDITIONAL([HAVE_BTREE_H], [test -f ${srcdir}/cpp-btree/btree.h]) if test "x$have_btree_h" = "x1"; then
AM_COND_IF([HAVE_BTREE_H],
[AC_MSG_RESULT([found])
have_btree_h=1],
[AC_MSG_RESULT([no])])
if test x$have_btree_h = x1 && ! test ${HAVE_HG_BIN}; then
AC_VERBOSE([Using already existing btree.]) AC_VERBOSE([Using already existing btree.])
AM_CONDITIONAL([BUILD_WITH_BTREE], [true]) AM_CONDITIONAL([BUILD_WITH_BTREE], [true])
elif ${HAVE_HG_BIN} && test x$have_btree_h != x1; then elif test "x$have_hg_bin" = "x1"; then
AC_VERBOSE([Downloading btree headers with mercurial]) AC_VERBOSE([
* Downloading btree headers with mercurial
])
$(which hg) clone https://code.google.com/p/cpp-btree/ $(which hg) clone https://code.google.com/p/cpp-btree/
AM_CONDITIONAL([BUILD_WITH_BTREE], [true])
else else
AC_VERBOSE([ AC_VERBOSE([
* Could not find hg in $PATH * Could not find hg in your PATH
* Building with STL maps instead of Google Btree * Building with STL maps instead of Google Btree
]) ])
AM_CONDITIONAL([BUILD_WITH_BTREE], [false]) AM_CONDITIONAL([BUILD_WITH_BTREE], [false])

View File

@ -6,16 +6,13 @@ using namespace pipecolors;
int main(void) { int main(void) {
char buffer[128]; char buffer[256];
char * buf;
int num = 5; int num = 5;
const char* str = "My number is"; const char* str = "My number is";
const char* str2 = "|10My number is|07"; const char* str2 = "|10My number is|07";
int len = pcprintf("|01%s |41|09%d|39\n", str, num); int len = pcprintf("|01%s |09%d|39\n", str, num);
pcprintf("|10Length of Len is : |15|30%d\n|07", len); pcprintf("|10Length of Len is : |15|30%d\n|07", len);
int len2 = pcsprintf(buffer, "%s %d\n", str2, num); int len2 = pcsprintf(buffer, "%s %d\n", str2, num);
printf("\n%s %d\n", buffer, len2); printf("\n%s %d\n", buffer, len2);
int len3 = asprintf(&buf, "%s %d\n", str2, num);
printf("\n%s %d\n", buf, len3);
return 0; return 0;
} }

View File

@ -27,14 +27,18 @@
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <cstdarg> #include <cstdarg>
#include <map>
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include "pipecolors.h" #include "pipecolors.h"
namespace pipecolors { namespace pipecolors {
//typedef btree::btree_map<std::string, std::string> colors; #ifndef BUILD_WITH_BTREE
#include <map>
typedef std::map<std::string, std::string> colorMap; typedef std::map<std::string, std::string> colorMap;
#else
#include "cpp-btree/btree_map.h"
typedef btree::btree_map<std::string, std::string> colorMap;
#endif
colorMap getColors() { colorMap getColors() {
colorMap colors; colorMap colors;