sqlpp11C++ 安全 SQL 模版库
sqlpp11 是 C++ 的类型安全 SQL 模版库。
sqlpp11 是一个嵌入式领域特定语言(EDSL)的代表模版库:
-
为表和列定义类型
-
在编译的时候检查结构类型安全查询(语法错误,类型错误,命名错误,甚至是一些语义错误)
-
通过迭代 query-specific 结构得到解析结果
示例
CREATE TABLE foo ( id bigint, name varchar(50), hasFun bool );
假设有个数据库连接对象:
TabFoo foo; Db db(/* some arguments*/); // selecting zero or more results, iterating over the results for (const auto& row : db(select(foo.name, foo.hasFun).from(foo).where(foo.id > 17 and foo.name.like("%bar%")))) { if (row.name.is_null()) std::cerr << "name is null, will convert to empty string" << std::endl; std::string name = row.name; // string-like fields are implicitly convertible to string bool hasFun = row.hasFun; // bool fields are implicitly convertible to bool } // selecting ALL columns of a table for (const auto& row : db(select(all_of(foo)).from(foo).where(foo.hasFun or foo.name == "joker"))) { int64_t id = row.id; // numeric fields are implicitly convertible to numeric c++ types } // selecting zero or one row, showing off with an alias: SQLPP_ALIAS_PROVIDER(cheese); if (const auto& row = db(select(foo.name.as(cheese)).from(foo).where(foo.id == 17))) { std::cerr << "found: " << row.cheese << std::endl; } // selecting a single row with a single result: return db(select(count(foo.id)).from(foo).where(true)).front().count; Of course there are joins and subqueries, more functions, order_by, group_by etc. These will be documented soon. // A sample insert db(insert_into(foo).set(foo.id = 17, foo.name = "bar", foo.hasFun = true)); // A sample update db(update(foo).set(foo.hasFun = not foo.hasFun).where(foo.name != "nobody")); // A sample delete db(remove_from(foo).where(not foo.hasFun));
评论
TapkeeC++ 模版库
Tapkee是一个C++模版库,提供了降维操作功能。Tapkee起源于GSoC2011期间开发的代码 ,它是Shogun机器学习工具箱的一部分。该项目的目标是为减少维度提供高效灵活的独立库,该库可轻松
TapkeeC++ 模版库
0
DTLC++ 数据库模版库
DTL(DatabaseTemplateLibrary)是一个ODBC记录集的封装,使之像一个STL容器。DTL还是一个ODBC的抽象层使之可以支持多种平台和各种C++编译器。通过DTL,你可以使用S
DTLC++ 数据库模版库
0
cJinja轻量html模版渲染库
介绍cJinja是一个使用cpp编写的轻量html模版解析库,依赖 ejson 来实现模版的数据替换(在jinja中称为context,上下文)。模版的语法基本与djangojinja一致,功能还算丰
cJinja轻量html模版渲染库
0
buji-pac4jShiro 的 pac4j 安全库
buji-pac4j项目是ShiroWeb应用程序的一个简单而强大的安全库,它支持身份验证和授权,还提供了诸如CSRF保护等高级功能。它基于Java8、Shiro1.4和pac4j安全引擎v2。
buji-pac4jShiro 的 pac4j 安全库
0
spring-security-pac4jSpring Security 的 pac4j 安全库
spring-security-pac4j项目是SpringSecurity(带或不带SpringBoot)Web应用程序的简单而强大的安全库。它支持身份验证和授权,还支持会话固定和CSRF保护等高级
spring-security-pac4jSpring Security 的 pac4j 安全库
0
undertow-pac4jUndertow Web 应用的安全库
对于 Undertow Web 应用程序,undertow-pac4j 项目是一个简单而强大的安全库
undertow-pac4jUndertow Web 应用的安全库
0