restructure third-parties, add licenses, add more gcc-compiler tests

This commit is contained in:
pantor
2017-08-14 09:35:37 +02:00
parent 7bb461267a
commit 466a378a08
8 changed files with 139 additions and 42 deletions

View File

@@ -7,57 +7,64 @@ language: cpp
dist: trusty
sudo: required
#addons:
# apt:
# sources:
# # add PPAs with more up-to-date toolchains
# - ubuntu-toolchain-r-test
# - llvm-toolchain-precise-3.6
# packages:
# # install toolchains
# - gcc-5
# - g++-5
# - clang-3.6
matrix:
include:
### Coveralls ###
- compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
env: COMPILER=g++-4.9
- compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-5
sources: ['ubuntu-toolchain-r-test']
packages: g++-5
env: COMPILER=g++-5
before_install:
- pip install --user cpp-coveralls
after_success:
- make clean
# - coveralls --exclude lib --exclude tests --gcov-options '\-lp'
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-4.9
env: COMPILER=g++-4.9
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-5
env: COMPILER=g++-5
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-6
env: COMPILER=g++-6
- compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-7
env: COMPILER=g++-7
- compiler: clang
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
packages:
- clang-3.6
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: clang-3.6
env: COMPILER=clang++-3.6
- compiler: clang
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
packages:
- clang-3.7
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
packages: clang-3.7
env: COMPILER=clang++-3.7
before_install:
- pip install --user cpp-coveralls
script:
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
- uname -a
@@ -67,5 +74,3 @@ script:
- cmake .. && cmake --build . --config Release -- -j4
- ctest -C Release -V
- cd ..
#after_success:
# - coveralls --exclude lib --exclude tests --gcov-options '\-lp'

View File

@@ -5,4 +5,33 @@ A Template Engine for Modern C++
[![Build Status](https://travis-ci.org/pantor/inja.svg?branch=master)](https://travis-ci.org/pantor/inja)
[![Coverage Status](https://img.shields.io/coveralls/pantor/inja.svg)](https://coveralls.io/r/pantor/inja)
[![Github Issues](https://img.shields.io/github/issues/pantor/inja.svg)](http://github.com/pantor/inja/issues)
[![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/pantor/inja/master/LICENSE.MIT)
[![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/pantor/inja/master/LICENSE)
json data = {{"name", "world"}};
string result = inja::render("Hello {{ world }}!", data);
// "Hello World!"
## Integration
Inja is headers only. Just one dependency: json by nlohmann.
#include "json.hpp"
#include "inja.hpp"
## Examples
## Supported compilers
Currently, the following compilers are tested:
- GCC 4.9 - 7.1 (and possibly later)
- Clang 3.6 - 3.7 (and possibly later)
## License
The class is licensed under the [MIT License](https://raw.githubusercontent.com/pantor/inja/master/LICENSE).

View File

@@ -1,10 +1,19 @@
/*
Inja - A Template Engine for Modern C++
*/
#ifndef PANTOR_INJA_HPP
#define PANTOR_INJA_HPP
#include <iostream>
#include <fstream>
#include <string>
#include <regex>
#include "json/json.hpp"
#ifndef NLOHMANN_JSON_HPP
static_assert(false, "nlohmann/json not found.");
#endif
namespace inja {
@@ -428,4 +437,11 @@ public:
}
};
} // namespace inja
string render(string input, json data) {
Environment env = Environment();
return env.render(input, data);
}
} // namespace inja
#endif // PANTOR_INJA_HPP

View File

@@ -1,6 +1,7 @@
#define CATCH_CONFIG_MAIN
#include "../thirdparty/catch.hpp"
#include "../thirdparty/catch/catch.hpp"
#include "../thirdparty/json/json.hpp"
#include "../../src/inja.hpp"
@@ -212,6 +213,8 @@ TEST_CASE("Render") {
REQUIRE( env.render("(% if age != 28 %)Right(% else %)Wrong(% endif %)", data) == "Right" );
REQUIRE( env.render("(% if age >= 30 %)Right(% else %)Wrong(% endif %)", data) == "Wrong" );
REQUIRE( env.render("(% if age in [28, 29, 30] %)True(% endif %)", data) == "True" );
// Only works with gcc-5
// REQUIRE( env.render("(% if name in [\"Simon\", \"Tom\"] %)Test1(% else if name in [\"Peter\"] %)Test2(% else %)Test3(% endif %)", data) == "Test2" );
}
}

23
test/thirdparty/catch/LICENSE.txt vendored Normal file
View File

@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

21
test/thirdparty/json/LICENSE.MIT vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2013-2017 Niels Lohmann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.