├── support ├── AndroidManifest.xml ├── rtd │ ├── theme │ │ ├── theme.conf │ │ └── layout.html │ ├── index.rst │ └── conf.py ├── cmake │ ├── fmt-config.cmake.in │ ├── FindSetEnv.cmake │ ├── run-cmake.bat │ └── cxx14.cmake ├── README ├── Android.mk ├── appveyor.yml ├── fmt.pro ├── update-coverity-branch.py ├── appveyor-build.py ├── compute-powers.py ├── build.gradle ├── rst2md.py └── travis-build.py ├── doc ├── basic-bootstrap │ ├── theme.conf │ └── README ├── _static │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ └── breathe.css ├── contents.rst ├── bootstrap │ ├── mixins │ │ ├── center-block.less │ │ ├── text-emphasis.less │ │ ├── size.less │ │ ├── opacity.less │ │ ├── background-variant.less │ │ ├── text-overflow.less │ │ ├── tab-focus.less │ │ ├── resize.less │ │ ├── labels.less │ │ ├── progress-bar.less │ │ ├── reset-filter.less │ │ ├── nav-divider.less │ │ ├── alerts.less │ │ ├── nav-vertical-align.less │ │ ├── responsive-visibility.less │ │ ├── pagination.less │ │ ├── border-radius.less │ │ ├── panels.less │ │ ├── list-group.less │ │ ├── hide-text.less │ │ ├── clearfix.less │ │ ├── table-row.less │ │ ├── image.less │ │ ├── buttons.less │ │ ├── forms.less │ │ ├── grid-framework.less │ │ ├── grid.less │ │ └── gradients.less │ ├── wells.less │ ├── breadcrumbs.less │ ├── responsive-embed.less │ ├── component-animations.less │ ├── close.less │ ├── thumbnails.less │ ├── utilities.less │ ├── media.less │ ├── pager.less │ ├── jumbotron.less │ ├── mixins.less │ ├── bootstrap.less │ ├── labels.less │ ├── badges.less │ ├── code.less │ ├── grid.less │ ├── alerts.less │ ├── progress-bars.less │ ├── pagination.less │ ├── print.less │ ├── tooltip.less │ ├── list-group.less │ ├── scaffolding.less │ ├── popovers.less │ ├── modals.less │ ├── buttons.less │ ├── input-groups.less │ ├── responsive-utilities.less │ ├── tables.less │ ├── dropdowns.less │ ├── navs.less │ ├── carousel.less │ └── button-groups.less ├── CMakeLists.txt ├── fmt.less ├── _templates │ ├── search.html │ └── layout.html ├── usage.rst └── build.py ├── test ├── header-only-test.cc ├── header-only-test2.cc ├── find-package-test │ ├── main.cc │ └── CMakeLists.txt ├── add-subdirectory-test │ ├── main.cc │ └── CMakeLists.txt ├── assert-test.cc ├── test-assert.h ├── util.cc ├── test-main.cc ├── time-test.cc ├── mock-allocator.h ├── posix-mock.h ├── custom-formatter-test.cc ├── util.h ├── gtest-extra.cc ├── compile-test │ └── CMakeLists.txt ├── ranges-test.cc └── gtest-extra.h ├── CONTRIBUTING.rst ├── .gitignore ├── LICENSE.rst ├── src └── format.cc ├── .travis.yml └── include └── fmt ├── time.h └── ostream.h /support/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/basic-bootstrap/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | -------------------------------------------------------------------------------- /support/rtd/theme/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | -------------------------------------------------------------------------------- /test/header-only-test.cc: -------------------------------------------------------------------------------- 1 | // Header-only configuration test 2 | 3 | #include "fmt/core.h" 4 | -------------------------------------------------------------------------------- /test/header-only-test2.cc: -------------------------------------------------------------------------------- 1 | // Additional translation unit for the header-only configuration test 2 | 3 | #include "fmt/core.h" 4 | -------------------------------------------------------------------------------- /support/rtd/index.rst: -------------------------------------------------------------------------------- 1 | If you are not redirected automatically, follow the 2 | `link to the fmt documentation `_. 3 | -------------------------------------------------------------------------------- /doc/_static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scylladb/fmt/HEAD/doc/_static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /doc/_static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scylladb/fmt/HEAD/doc/_static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /doc/_static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scylladb/fmt/HEAD/doc/_static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /doc/contents.rst: -------------------------------------------------------------------------------- 1 | ######## 2 | Contents 3 | ######## 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | 8 | usage 9 | api 10 | syntax 11 | -------------------------------------------------------------------------------- /support/cmake/fmt-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake) 4 | check_required_components(fmt) 5 | -------------------------------------------------------------------------------- /support/README: -------------------------------------------------------------------------------- 1 | This directory contains build support files such as 2 | 3 | * CMake modules 4 | * Build scripts 5 | * qmake (static build with dynamic libc only) 6 | 7 | -------------------------------------------------------------------------------- /support/rtd/conf.py: -------------------------------------------------------------------------------- 1 | # Sphinx configuration for readthedocs. 2 | 3 | import os, sys 4 | 5 | master_doc = 'index' 6 | html_theme = 'theme' 7 | html_theme_path = ["."] 8 | -------------------------------------------------------------------------------- /doc/basic-bootstrap/README: -------------------------------------------------------------------------------- 1 | Sphinx basic theme with Bootstrap support. Modifications are kept to 2 | a minimum to simplify integration in case of changes to Sphinx theming. 3 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/center-block.less: -------------------------------------------------------------------------------- 1 | // Center-align a block level element 2 | 3 | .center-block() { 4 | display: block; 5 | margin-left: auto; 6 | margin-right: auto; 7 | } 8 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/text-emphasis.less: -------------------------------------------------------------------------------- 1 | // Typography 2 | 3 | .text-emphasis-variant(@color) { 4 | color: @color; 5 | a&:hover { 6 | color: darken(@color, 10%); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/find-package-test/main.cc: -------------------------------------------------------------------------------- 1 | #include "fmt/format.h" 2 | 3 | int main(int argc, char** argv) { 4 | for(int i = 0; i < argc; ++i) 5 | fmt::print("{}: {}\n", i, argv[i]); 6 | } 7 | -------------------------------------------------------------------------------- /test/add-subdirectory-test/main.cc: -------------------------------------------------------------------------------- 1 | #include "fmt/format.h" 2 | 3 | int main(int argc, char** argv) { 4 | for(int i = 0; i < argc; ++i) 5 | fmt::print("{}: {}\n", i, argv[i]); 6 | } 7 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/size.less: -------------------------------------------------------------------------------- 1 | // Sizing shortcuts 2 | 3 | .size(@width; @height) { 4 | width: @width; 5 | height: @height; 6 | } 7 | 8 | .square(@size) { 9 | .size(@size; @size); 10 | } 11 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/opacity.less: -------------------------------------------------------------------------------- 1 | // Opacity 2 | 3 | .opacity(@opacity) { 4 | opacity: @opacity; 5 | // IE8 filter 6 | @opacity-ie: (@opacity * 100); 7 | filter: ~"alpha(opacity=@{opacity-ie})"; 8 | } 9 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/background-variant.less: -------------------------------------------------------------------------------- 1 | // Contextual backgrounds 2 | 3 | .bg-variant(@color) { 4 | background-color: @color; 5 | a&:hover { 6 | background-color: darken(@color, 10%); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/text-overflow.less: -------------------------------------------------------------------------------- 1 | // Text overflow 2 | // Requires inline-block or block for proper styling 3 | 4 | .text-overflow() { 5 | overflow: hidden; 6 | text-overflow: ellipsis; 7 | white-space: nowrap; 8 | } 9 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/tab-focus.less: -------------------------------------------------------------------------------- 1 | // WebKit-style focus 2 | 3 | .tab-focus() { 4 | // Default 5 | outline: thin dotted; 6 | // WebKit 7 | outline: 5px auto -webkit-focus-ring-color; 8 | outline-offset: -2px; 9 | } 10 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/resize.less: -------------------------------------------------------------------------------- 1 | // Resize anything 2 | 3 | .resizable(@direction) { 4 | resize: @direction; // Options: horizontal, vertical, both 5 | overflow: auto; // Per CSS3 UI, `resize` only applies when `overflow` isn't `visible` 6 | } 7 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/labels.less: -------------------------------------------------------------------------------- 1 | // Labels 2 | 3 | .label-variant(@color) { 4 | background-color: @color; 5 | 6 | &[href] { 7 | &:hover, 8 | &:focus { 9 | background-color: darken(@color, 10%); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/progress-bar.less: -------------------------------------------------------------------------------- 1 | // Progress bars 2 | 3 | .progress-bar-variant(@color) { 4 | background-color: @color; 5 | 6 | // Deprecated parent class requirement as of v3.2.0 7 | .progress-striped & { 8 | #gradient > .striped(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/reset-filter.less: -------------------------------------------------------------------------------- 1 | // Reset filters for IE 2 | // 3 | // When you need to remove a gradient background, do not forget to use this to reset 4 | // the IE filter for IE9 and below. 5 | 6 | .reset-filter() { 7 | filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)")); 8 | } 9 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/nav-divider.less: -------------------------------------------------------------------------------- 1 | // Horizontal dividers 2 | // 3 | // Dividers (basically an hr) within dropdowns and nav lists 4 | 5 | .nav-divider(@color: #e5e5e5) { 6 | height: 1px; 7 | margin: ((@line-height-computed / 2) - 1) 0; 8 | overflow: hidden; 9 | background-color: @color; 10 | } 11 | -------------------------------------------------------------------------------- /support/cmake/FindSetEnv.cmake: -------------------------------------------------------------------------------- 1 | # A CMake script to find SetEnv.cmd. 2 | 3 | find_program(WINSDK_SETENV NAMES SetEnv.cmd 4 | PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]/bin") 5 | if (WINSDK_SETENV AND PRINT_PATH) 6 | execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${WINSDK_SETENV}") 7 | endif () 8 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/alerts.less: -------------------------------------------------------------------------------- 1 | // Alerts 2 | 3 | .alert-variant(@background; @border; @text-color) { 4 | background-color: @background; 5 | border-color: @border; 6 | color: @text-color; 7 | 8 | hr { 9 | border-top-color: darken(@border, 5%); 10 | } 11 | .alert-link { 12 | color: darken(@text-color, 10%); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | Contributing to fmt 2 | =================== 3 | 4 | All C++ code must adhere to `Google C++ Style Guide 5 | `_ with the following 6 | exceptions: 7 | 8 | * Exceptions are permitted 9 | * snake_case should be used instead of UpperCamelCase for function and type 10 | names 11 | 12 | Thanks for contributing! 13 | -------------------------------------------------------------------------------- /support/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_MODULE := fmt_static 5 | LOCAL_MODULE_FILENAME := libfmt 6 | 7 | LOCAL_SRC_FILES := ../src/format.cc 8 | 9 | LOCAL_C_INCLUDES := $(LOCAL_PATH) 10 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) 11 | 12 | LOCAL_CFLAGS += -std=c++11 -fexceptions 13 | 14 | include $(BUILD_STATIC_LIBRARY) 15 | 16 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/nav-vertical-align.less: -------------------------------------------------------------------------------- 1 | // Navbar vertical align 2 | // 3 | // Vertically center elements in the navbar. 4 | // Example: an element has a height of 30px, so write out `.navbar-vertical-align(30px);` to calculate the appropriate top margin. 5 | 6 | .navbar-vertical-align(@element-height) { 7 | margin-top: ((@navbar-height - @element-height) / 2); 8 | margin-bottom: ((@navbar-height - @element-height) / 2); 9 | } 10 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/responsive-visibility.less: -------------------------------------------------------------------------------- 1 | // Responsive utilities 2 | 3 | // 4 | // More easily include all the states for responsive-utilities.less. 5 | .responsive-visibility() { 6 | display: block !important; 7 | table& { display: table; } 8 | tr& { display: table-row !important; } 9 | th&, 10 | td& { display: table-cell !important; } 11 | } 12 | 13 | .responsive-invisibility() { 14 | display: none !important; 15 | } 16 | -------------------------------------------------------------------------------- /support/cmake/run-cmake.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | rem This scripts configures build environment and runs CMake. 3 | rem Use it instead of running CMake directly when building with 4 | rem the Microsoft SDK toolchain rather than Visual Studio. 5 | rem It is used in the same way as cmake, for example: 6 | rem 7 | rem run-cmake -G "Visual Studio 10 Win64" . 8 | 9 | for /F "delims=" %%i IN ('cmake "-DPRINT_PATH=1" -P %~dp0/FindSetEnv.cmake') DO set setenv=%%i 10 | if NOT "%setenv%" == "" call "%setenv%" 11 | cmake %* 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | 3 | *.iml 4 | .idea/ 5 | .externalNativeBuild/ 6 | .gradle/ 7 | gradle/ 8 | gradlew* 9 | local.properties 10 | build/ 11 | 12 | bin/ 13 | /_CPack_Packages 14 | /CMakeScripts 15 | /doc/doxyxml 16 | /doc/html 17 | virtualenv 18 | /Testing 19 | /install_manifest.txt 20 | *~ 21 | *.a 22 | *.so* 23 | *.xcodeproj 24 | *.zip 25 | cmake_install.cmake 26 | CPack*.cmake 27 | fmt-*.cmake 28 | CTestTestfile.cmake 29 | CMakeCache.txt 30 | CMakeFiles 31 | FMT.build 32 | Makefile 33 | run-msbuild.bat 34 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/pagination.less: -------------------------------------------------------------------------------- 1 | // Pagination 2 | 3 | .pagination-size(@padding-vertical; @padding-horizontal; @font-size; @border-radius) { 4 | > li { 5 | > a, 6 | > span { 7 | padding: @padding-vertical @padding-horizontal; 8 | font-size: @font-size; 9 | } 10 | &:first-child { 11 | > a, 12 | > span { 13 | .border-left-radius(@border-radius); 14 | } 15 | } 16 | &:last-child { 17 | > a, 18 | > span { 19 | .border-right-radius(@border-radius); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/border-radius.less: -------------------------------------------------------------------------------- 1 | // Single side border-radius 2 | 3 | .border-top-radius(@radius) { 4 | border-top-right-radius: @radius; 5 | border-top-left-radius: @radius; 6 | } 7 | .border-right-radius(@radius) { 8 | border-bottom-right-radius: @radius; 9 | border-top-right-radius: @radius; 10 | } 11 | .border-bottom-radius(@radius) { 12 | border-bottom-right-radius: @radius; 13 | border-bottom-left-radius: @radius; 14 | } 15 | .border-left-radius(@radius) { 16 | border-bottom-left-radius: @radius; 17 | border-top-left-radius: @radius; 18 | } 19 | -------------------------------------------------------------------------------- /support/rtd/theme/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "basic/layout.html" %} 2 | 3 | {% block extrahead %} 4 | 5 | 6 | 9 | Page Redirection 10 | {% endblock %} 11 | 12 | {% block document %} 13 | If you are not redirected automatically, follow the link to the fmt documentation. 14 | {% endblock %} 15 | 16 | {% block footer %} 17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_program(DOXYGEN doxygen) 2 | if (NOT DOXYGEN) 3 | message(STATUS "Target 'doc' disabled (requires doxygen)") 4 | return () 5 | endif () 6 | 7 | find_package(PythonInterp 8 | QUIET REQUIRED) 9 | find_program(SPHINX_EXECUTABLE 10 | NAMES sphinx-build sphinx-build-3) 11 | add_custom_target(doc 12 | COMMAND ${CMAKE_COMMAND} -E env SPHINX_EXECUTABLE=${SPHINX_EXECUTABLE} 13 | ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/build.py ${FMT_VERSION} 14 | SOURCES api.rst syntax.rst build.py conf.py _templates/layout.html) 15 | 16 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ 17 | DESTINATION share/doc/fmt OPTIONAL) 18 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/panels.less: -------------------------------------------------------------------------------- 1 | // Panels 2 | 3 | .panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border) { 4 | border-color: @border; 5 | 6 | & > .panel-heading { 7 | color: @heading-text-color; 8 | background-color: @heading-bg-color; 9 | border-color: @heading-border; 10 | 11 | + .panel-collapse > .panel-body { 12 | border-top-color: @border; 13 | } 14 | .badge { 15 | color: @heading-bg-color; 16 | background-color: @heading-text-color; 17 | } 18 | } 19 | & > .panel-footer { 20 | + .panel-collapse > .panel-body { 21 | border-bottom-color: @border; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /doc/bootstrap/wells.less: -------------------------------------------------------------------------------- 1 | // 2 | // Wells 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .well { 8 | min-height: 20px; 9 | padding: 19px; 10 | margin-bottom: 20px; 11 | background-color: @well-bg; 12 | border: 1px solid @well-border; 13 | border-radius: @border-radius-base; 14 | .box-shadow(inset 0 1px 1px rgba(0,0,0,.05)); 15 | blockquote { 16 | border-color: #ddd; 17 | border-color: rgba(0,0,0,.15); 18 | } 19 | } 20 | 21 | // Sizes 22 | .well-lg { 23 | padding: 24px; 24 | border-radius: @border-radius-large; 25 | } 26 | .well-sm { 27 | padding: 9px; 28 | border-radius: @border-radius-small; 29 | } 30 | -------------------------------------------------------------------------------- /doc/_static/breathe.css: -------------------------------------------------------------------------------- 1 | 2 | /* -- breathe specific styles ----------------------------------------------- */ 3 | 4 | /* So enum value descriptions are displayed inline to the item */ 5 | .breatheenumvalues li tt + p { 6 | display: inline; 7 | } 8 | 9 | /* So parameter descriptions are displayed inline to the item */ 10 | .breatheparameterlist li tt + p { 11 | display: inline; 12 | } 13 | 14 | .container .breathe-sectiondef { 15 | width: inherit; 16 | } 17 | 18 | .github-btn { 19 | border: 0; 20 | overflow: hidden; 21 | } 22 | 23 | .jumbotron { 24 | background-size: 100% 4px; 25 | background-repeat: repeat-y; 26 | color: white; 27 | text-align: center; 28 | } 29 | -------------------------------------------------------------------------------- /test/find-package-test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1.0) 2 | 3 | project(fmt-test) 4 | 5 | find_package(FMT REQUIRED) 6 | 7 | add_executable(library-test main.cc) 8 | target_link_libraries(library-test fmt::fmt) 9 | target_compile_options(library-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) 10 | target_include_directories(library-test PUBLIC SYSTEM .) 11 | 12 | if (TARGET fmt::fmt-header-only) 13 | add_executable(header-only-test main.cc) 14 | target_link_libraries(header-only-test fmt::fmt-header-only) 15 | target_compile_options(header-only-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) 16 | target_include_directories(header-only-test PUBLIC SYSTEM .) 17 | endif () 18 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/list-group.less: -------------------------------------------------------------------------------- 1 | // List Groups 2 | 3 | .list-group-item-variant(@state; @background; @color) { 4 | .list-group-item-@{state} { 5 | color: @color; 6 | background-color: @background; 7 | 8 | a& { 9 | color: @color; 10 | 11 | .list-group-item-heading { 12 | color: inherit; 13 | } 14 | 15 | &:hover, 16 | &:focus { 17 | color: @color; 18 | background-color: darken(@background, 5%); 19 | } 20 | &.active, 21 | &.active:hover, 22 | &.active:focus { 23 | color: #fff; 24 | background-color: @color; 25 | border-color: @color; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/add-subdirectory-test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1.0) 2 | 3 | project(fmt-test) 4 | 5 | add_subdirectory(../.. fmt) 6 | 7 | add_executable(library-test "main.cc") 8 | target_link_libraries(library-test fmt::fmt) 9 | target_compile_options(library-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) 10 | target_include_directories(library-test PUBLIC SYSTEM .) 11 | 12 | if (TARGET fmt::fmt-header-only) 13 | add_executable(header-only-test "main.cc") 14 | target_link_libraries(header-only-test fmt::fmt-header-only) 15 | target_compile_options(header-only-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) 16 | target_include_directories(header-only-test PUBLIC SYSTEM .) 17 | endif () 18 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/hide-text.less: -------------------------------------------------------------------------------- 1 | // CSS image replacement 2 | // 3 | // Heads up! v3 launched with with only `.hide-text()`, but per our pattern for 4 | // mixins being reused as classes with the same name, this doesn't hold up. As 5 | // of v3.0.1 we have added `.text-hide()` and deprecated `.hide-text()`. 6 | // 7 | // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757 8 | 9 | // Deprecated as of v3.0.1 (will be removed in v4) 10 | .hide-text() { 11 | font: ~"0/0" a; 12 | color: transparent; 13 | text-shadow: none; 14 | background-color: transparent; 15 | border: 0; 16 | } 17 | 18 | // New mixin to use as of v3.0.1 19 | .text-hide() { 20 | .hide-text(); 21 | } 22 | -------------------------------------------------------------------------------- /test/assert-test.cc: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - assertion tests 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #include "fmt/core.h" 9 | #include "gtest.h" 10 | 11 | #if GTEST_HAS_DEATH_TEST 12 | # define EXPECT_DEBUG_DEATH_IF_SUPPORTED(statement, regex) \ 13 | EXPECT_DEBUG_DEATH(statement, regex) 14 | #else 15 | # define EXPECT_DEBUG_DEATH_IF_SUPPORTED(statement, regex) \ 16 | GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, ) 17 | #endif 18 | 19 | TEST(AssertTest, Fail) { 20 | EXPECT_DEBUG_DEATH_IF_SUPPORTED( 21 | FMT_ASSERT(false, "don't panic!"), "don't panic!"); 22 | } 23 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/clearfix.less: -------------------------------------------------------------------------------- 1 | // Clearfix 2 | // 3 | // For modern browsers 4 | // 1. The space content is one way to avoid an Opera bug when the 5 | // contenteditable attribute is included anywhere else in the document. 6 | // Otherwise it causes space to appear at the top and bottom of elements 7 | // that are clearfixed. 8 | // 2. The use of `table` rather than `block` is only necessary if using 9 | // `:before` to contain the top-margins of child elements. 10 | // 11 | // Source: http://nicolasgallagher.com/micro-clearfix-hack/ 12 | 13 | .clearfix() { 14 | &:before, 15 | &:after { 16 | content: " "; // 1 17 | display: table; // 2 18 | } 19 | &:after { 20 | clear: both; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /doc/bootstrap/breadcrumbs.less: -------------------------------------------------------------------------------- 1 | // 2 | // Breadcrumbs 3 | // -------------------------------------------------- 4 | 5 | 6 | .breadcrumb { 7 | padding: @breadcrumb-padding-vertical @breadcrumb-padding-horizontal; 8 | margin-bottom: @line-height-computed; 9 | list-style: none; 10 | background-color: @breadcrumb-bg; 11 | border-radius: @border-radius-base; 12 | 13 | > li { 14 | display: inline-block; 15 | 16 | + li:before { 17 | content: "@{breadcrumb-separator}\00a0"; // Unicode space added since inline-block means non-collapsing white-space 18 | padding: 0 5px; 19 | color: @breadcrumb-color; 20 | } 21 | } 22 | 23 | > .active { 24 | color: @breadcrumb-active-color; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /doc/bootstrap/responsive-embed.less: -------------------------------------------------------------------------------- 1 | // Embeds responsive 2 | // 3 | // Credit: Nicolas Gallagher and SUIT CSS. 4 | 5 | .embed-responsive { 6 | position: relative; 7 | display: block; 8 | height: 0; 9 | padding: 0; 10 | overflow: hidden; 11 | 12 | .embed-responsive-item, 13 | iframe, 14 | embed, 15 | object, 16 | video { 17 | position: absolute; 18 | top: 0; 19 | left: 0; 20 | bottom: 0; 21 | height: 100%; 22 | width: 100%; 23 | border: 0; 24 | } 25 | } 26 | 27 | // Modifier class for 16:9 aspect ratio 28 | .embed-responsive-16by9 { 29 | padding-bottom: 56.25%; 30 | } 31 | 32 | // Modifier class for 4:3 aspect ratio 33 | .embed-responsive-4by3 { 34 | padding-bottom: 75%; 35 | } 36 | -------------------------------------------------------------------------------- /support/appveyor.yml: -------------------------------------------------------------------------------- 1 | configuration: 2 | - Debug 3 | - Release 4 | 5 | clone_depth: 1 6 | 7 | platform: 8 | - Win32 9 | - x64 10 | 11 | image: 12 | - Visual Studio 2013 13 | - Visual Studio 2015 14 | - Visual Studio 2017 15 | 16 | environment: 17 | CTEST_OUTPUT_ON_FAILURE: 1 18 | MSVC_DEFAULT_OPTIONS: ON 19 | BUILD: msvc 20 | 21 | before_build: 22 | - mkdir build 23 | - cd build 24 | 25 | build_script: 26 | - python ../support/appveyor-build.py 27 | 28 | on_failure: 29 | - appveyor PushArtifact Testing/Temporary/LastTest.log 30 | - appveyor AddTest test 31 | 32 | # Uncomment this to debug AppVeyor failures. 33 | #on_finish: 34 | # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) 35 | -------------------------------------------------------------------------------- /test/test-assert.h: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - test version of FMT_ASSERT 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #ifndef FMT_TEST_ASSERT_H_ 9 | #define FMT_TEST_ASSERT_H_ 10 | 11 | #include 12 | #include "gtest.h" 13 | 14 | class assertion_failure : public std::logic_error { 15 | public: 16 | explicit assertion_failure(const char *message) : std::logic_error(message) {} 17 | }; 18 | 19 | #define FMT_ASSERT(condition, message) \ 20 | if (!(condition)) throw assertion_failure(message); 21 | 22 | // Expects an assertion failure. 23 | #define EXPECT_ASSERT(stmt, message) \ 24 | FMT_TEST_THROW_(stmt, assertion_failure, message, GTEST_NONFATAL_FAILURE_) 25 | 26 | #endif // FMT_TEST_ASSERT_H_ 27 | -------------------------------------------------------------------------------- /doc/bootstrap/component-animations.less: -------------------------------------------------------------------------------- 1 | // 2 | // Component animations 3 | // -------------------------------------------------- 4 | 5 | // Heads up! 6 | // 7 | // We don't use the `.opacity()` mixin here since it causes a bug with text 8 | // fields in IE7-8. Source: https://github.com/twbs/bootstrap/pull/3552. 9 | 10 | .fade { 11 | opacity: 0; 12 | .transition(opacity .15s linear); 13 | &.in { 14 | opacity: 1; 15 | } 16 | } 17 | 18 | .collapse { 19 | display: none; 20 | 21 | &.in { display: block; } 22 | tr&.in { display: table-row; } 23 | tbody&.in { display: table-row-group; } 24 | } 25 | 26 | .collapsing { 27 | position: relative; 28 | height: 0; 29 | overflow: hidden; 30 | .transition-property(~"height, visibility"); 31 | .transition-duration(.35s); 32 | .transition-timing-function(ease); 33 | } 34 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/table-row.less: -------------------------------------------------------------------------------- 1 | // Tables 2 | 3 | .table-row-variant(@state; @background) { 4 | // Exact selectors below required to override `.table-striped` and prevent 5 | // inheritance to nested tables. 6 | .table > thead > tr, 7 | .table > tbody > tr, 8 | .table > tfoot > tr { 9 | > td.@{state}, 10 | > th.@{state}, 11 | &.@{state} > td, 12 | &.@{state} > th { 13 | background-color: @background; 14 | } 15 | } 16 | 17 | // Hover states for `.table-hover` 18 | // Note: this is not available for cells or rows within `thead` or `tfoot`. 19 | .table-hover > tbody > tr { 20 | > td.@{state}:hover, 21 | > th.@{state}:hover, 22 | &.@{state}:hover > td, 23 | &:hover > .@{state}, 24 | &.@{state}:hover > th { 25 | background-color: darken(@background, 5%); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /doc/bootstrap/close.less: -------------------------------------------------------------------------------- 1 | // 2 | // Close icons 3 | // -------------------------------------------------- 4 | 5 | 6 | .close { 7 | float: right; 8 | font-size: (@font-size-base * 1.5); 9 | font-weight: @close-font-weight; 10 | line-height: 1; 11 | color: @close-color; 12 | text-shadow: @close-text-shadow; 13 | .opacity(.2); 14 | 15 | &:hover, 16 | &:focus { 17 | color: @close-color; 18 | text-decoration: none; 19 | cursor: pointer; 20 | .opacity(.5); 21 | } 22 | 23 | // Additional properties for button version 24 | // iOS requires the button element instead of an anchor tag. 25 | // If you want the anchor version, it requires `href="#"`. 26 | // See https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile 27 | button& { 28 | padding: 0; 29 | cursor: pointer; 30 | background: transparent; 31 | border: 0; 32 | -webkit-appearance: none; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /doc/bootstrap/thumbnails.less: -------------------------------------------------------------------------------- 1 | // 2 | // Thumbnails 3 | // -------------------------------------------------- 4 | 5 | 6 | // Mixin and adjust the regular image class 7 | .thumbnail { 8 | display: block; 9 | padding: @thumbnail-padding; 10 | margin-bottom: @line-height-computed; 11 | line-height: @line-height-base; 12 | background-color: @thumbnail-bg; 13 | border: 1px solid @thumbnail-border; 14 | border-radius: @thumbnail-border-radius; 15 | .transition(border .2s ease-in-out); 16 | 17 | > img, 18 | a > img { 19 | &:extend(.img-responsive); 20 | margin-left: auto; 21 | margin-right: auto; 22 | } 23 | 24 | // Add a hover state for linked versions only 25 | a&:hover, 26 | a&:focus, 27 | a&.active { 28 | border-color: @link-color; 29 | } 30 | 31 | // Image captions 32 | .caption { 33 | padding: @thumbnail-caption-padding; 34 | color: @thumbnail-caption-color; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /doc/bootstrap/utilities.less: -------------------------------------------------------------------------------- 1 | // 2 | // Utility classes 3 | // -------------------------------------------------- 4 | 5 | 6 | // Floats 7 | // ------------------------- 8 | 9 | .clearfix { 10 | .clearfix(); 11 | } 12 | .center-block { 13 | .center-block(); 14 | } 15 | .pull-right { 16 | float: right !important; 17 | } 18 | .pull-left { 19 | float: left !important; 20 | } 21 | 22 | 23 | // Toggling content 24 | // ------------------------- 25 | 26 | // Note: Deprecated .hide in favor of .hidden or .sr-only (as appropriate) in v3.0.1 27 | .hide { 28 | display: none !important; 29 | } 30 | .show { 31 | display: block !important; 32 | } 33 | .invisible { 34 | visibility: hidden; 35 | } 36 | .text-hide { 37 | .text-hide(); 38 | } 39 | 40 | 41 | // Hide from screenreaders and browsers 42 | // 43 | // Credit: HTML5 Boilerplate 44 | 45 | .hidden { 46 | display: none !important; 47 | } 48 | 49 | 50 | // For Affix plugin 51 | // ------------------------- 52 | 53 | .affix { 54 | position: fixed; 55 | } 56 | -------------------------------------------------------------------------------- /support/fmt.pro: -------------------------------------------------------------------------------- 1 | # Staticlib configuration for qmake builds 2 | # For some reason qmake 3.1 fails to identify source dependencies and excludes format.cc and printf.cc 3 | # from compilation so it _MUST_ be called as qmake -nodepend 4 | # A workaround is implemented below: a custom compiler is defined which does not track dependencies 5 | 6 | TEMPLATE = lib 7 | 8 | TARGET = fmt 9 | 10 | QMAKE_EXT_CPP = .cc 11 | 12 | CONFIG = staticlib warn_on c++11 13 | 14 | FMT_SOURCES = \ 15 | ../src/format.cc \ 16 | ../src/posix.cc 17 | 18 | fmt.name = libfmt 19 | fmt.input = FMT_SOURCES 20 | fmt.output = ${QMAKE_FILE_BASE}$$QMAKE_EXT_OBJ 21 | fmt.clean = ${QMAKE_FILE_BASE}$$QMAKE_EXT_OBJ 22 | fmt.depends = ${QMAKE_FILE_IN} 23 | # QMAKE_RUN_CXX will not be expanded 24 | fmt.commands = $$QMAKE_CXX -c $$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_WARN_ON $$QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO $$QMAKE_CXXFLAGS_CXX11 ${QMAKE_FILE_IN} 25 | fmt.variable_out = OBJECTS 26 | fmt.CONFIG = no_dependencies no_link 27 | QMAKE_EXTRA_COMPILERS += fmt 28 | -------------------------------------------------------------------------------- /doc/bootstrap/media.less: -------------------------------------------------------------------------------- 1 | .media { 2 | // Proper spacing between instances of .media 3 | margin-top: 15px; 4 | 5 | &:first-child { 6 | margin-top: 0; 7 | } 8 | } 9 | 10 | .media, 11 | .media-body { 12 | zoom: 1; 13 | overflow: hidden; 14 | } 15 | 16 | .media-body { 17 | width: 10000px; 18 | } 19 | 20 | .media-object { 21 | display: block; 22 | } 23 | 24 | .media-right, 25 | .media > .pull-right { 26 | padding-left: 10px; 27 | } 28 | 29 | .media-left, 30 | .media > .pull-left { 31 | padding-right: 10px; 32 | } 33 | 34 | .media-left, 35 | .media-right, 36 | .media-body { 37 | display: table-cell; 38 | vertical-align: top; 39 | } 40 | 41 | .media-middle { 42 | vertical-align: middle; 43 | } 44 | 45 | .media-bottom { 46 | vertical-align: bottom; 47 | } 48 | 49 | // Reset margins on headings for tighter default spacing 50 | .media-heading { 51 | margin-top: 0; 52 | margin-bottom: 5px; 53 | } 54 | 55 | // Media list variation 56 | // 57 | // Undo default ul/ol styles 58 | .media-list { 59 | padding-left: 0; 60 | list-style: none; 61 | } 62 | -------------------------------------------------------------------------------- /support/update-coverity-branch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Update the coverity branch from the master branch. 3 | # It is not done automatically because Coverity Scan limits 4 | # the number of submissions per day. 5 | 6 | from __future__ import print_function 7 | import shutil, tempfile 8 | from subprocess import check_output, STDOUT 9 | 10 | class Git: 11 | def __init__(self, dir): 12 | self.dir = dir 13 | 14 | def __call__(self, *args): 15 | output = check_output(['git'] + list(args), cwd=self.dir, stderr=STDOUT) 16 | print(output) 17 | return output 18 | 19 | dir = tempfile.mkdtemp() 20 | try: 21 | git = Git(dir) 22 | git('clone', '-b', 'coverity', 'git@github.com:fmtlib/fmt.git', dir) 23 | output = git('merge', '-X', 'theirs', '--no-commit', 'origin/master') 24 | if 'Fast-forward' not in output: 25 | git('reset', 'HEAD', '.travis.yml') 26 | git('checkout', '--', '.travis.yml') 27 | git('commit', '-m', 'Update coverity branch') 28 | git('push') 29 | finally: 30 | shutil.rmtree(dir) 31 | -------------------------------------------------------------------------------- /doc/bootstrap/pager.less: -------------------------------------------------------------------------------- 1 | // 2 | // Pager pagination 3 | // -------------------------------------------------- 4 | 5 | 6 | .pager { 7 | padding-left: 0; 8 | margin: @line-height-computed 0; 9 | list-style: none; 10 | text-align: center; 11 | &:extend(.clearfix all); 12 | li { 13 | display: inline; 14 | > a, 15 | > span { 16 | display: inline-block; 17 | padding: 5px 14px; 18 | background-color: @pager-bg; 19 | border: 1px solid @pager-border; 20 | border-radius: @pager-border-radius; 21 | } 22 | 23 | > a:hover, 24 | > a:focus { 25 | text-decoration: none; 26 | background-color: @pager-hover-bg; 27 | } 28 | } 29 | 30 | .next { 31 | > a, 32 | > span { 33 | float: right; 34 | } 35 | } 36 | 37 | .previous { 38 | > a, 39 | > span { 40 | float: left; 41 | } 42 | } 43 | 44 | .disabled { 45 | > a, 46 | > a:hover, 47 | > a:focus, 48 | > span { 49 | color: @pager-disabled-color; 50 | background-color: @pager-bg; 51 | cursor: @cursor-disabled; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/image.less: -------------------------------------------------------------------------------- 1 | // Image Mixins 2 | // - Responsive image 3 | // - Retina image 4 | 5 | 6 | // Responsive image 7 | // 8 | // Keep images from scaling beyond the width of their parents. 9 | .img-responsive(@display: block) { 10 | display: @display; 11 | max-width: 100%; // Part 1: Set a maximum relative to the parent 12 | height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching 13 | } 14 | 15 | 16 | // Retina image 17 | // 18 | // Short retina mixin for setting background-image and -size. Note that the 19 | // spelling of `min--moz-device-pixel-ratio` is intentional. 20 | .img-retina(@file-1x; @file-2x; @width-1x; @height-1x) { 21 | background-image: url("@{file-1x}"); 22 | 23 | @media 24 | only screen and (-webkit-min-device-pixel-ratio: 2), 25 | only screen and ( min--moz-device-pixel-ratio: 2), 26 | only screen and ( -o-min-device-pixel-ratio: 2/1), 27 | only screen and ( min-device-pixel-ratio: 2), 28 | only screen and ( min-resolution: 192dpi), 29 | only screen and ( min-resolution: 2dppx) { 30 | background-image: url("@{file-2x}"); 31 | background-size: @width-1x @height-1x; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /doc/bootstrap/jumbotron.less: -------------------------------------------------------------------------------- 1 | // 2 | // Jumbotron 3 | // -------------------------------------------------- 4 | 5 | 6 | .jumbotron { 7 | padding: @jumbotron-padding (@jumbotron-padding / 2); 8 | margin-bottom: @jumbotron-padding; 9 | color: @jumbotron-color; 10 | background-color: @jumbotron-bg; 11 | 12 | h1, 13 | .h1 { 14 | color: @jumbotron-heading-color; 15 | } 16 | 17 | p { 18 | margin-bottom: (@jumbotron-padding / 2); 19 | font-size: @jumbotron-font-size; 20 | font-weight: 200; 21 | } 22 | 23 | > hr { 24 | border-top-color: darken(@jumbotron-bg, 10%); 25 | } 26 | 27 | .tb-container &, 28 | .container-fluid & { 29 | border-radius: @border-radius-large; // Only round corners at higher resolutions if contained in a container 30 | } 31 | 32 | .tb-container { 33 | max-width: 100%; 34 | } 35 | 36 | @media screen and (min-width: @screen-sm-min) { 37 | padding: (@jumbotron-padding * 1.6) 0; 38 | 39 | .tb-container &, 40 | .container-fluid & { 41 | padding-left: (@jumbotron-padding * 2); 42 | padding-right: (@jumbotron-padding * 2); 43 | } 44 | 45 | h1, 46 | .h1 { 47 | font-size: (@font-size-base * 4.5); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test/util.cc: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - test utilities 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #include "util.h" 9 | #include 10 | 11 | void increment(char *s) { 12 | for (int i = static_cast(std::strlen(s)) - 1; i >= 0; --i) { 13 | if (s[i] != '9') { 14 | ++s[i]; 15 | break; 16 | } 17 | s[i] = '0'; 18 | } 19 | } 20 | 21 | std::string get_system_error(int error_code) { 22 | #if defined(__MINGW32__) || !defined(_WIN32) 23 | return strerror(error_code); 24 | #else 25 | enum { BUFFER_SIZE = 200 }; 26 | char buffer[BUFFER_SIZE]; 27 | if (strerror_s(buffer, BUFFER_SIZE, error_code)) 28 | throw std::exception("strerror_s failed"); 29 | return buffer; 30 | #endif 31 | } 32 | 33 | const char *const FILE_CONTENT = "Don't panic!"; 34 | 35 | fmt::buffered_file open_buffered_file(FILE **fp) { 36 | fmt::file read_end, write_end; 37 | fmt::file::pipe(read_end, write_end); 38 | write_end.write(FILE_CONTENT, std::strlen(FILE_CONTENT)); 39 | write_end.close(); 40 | fmt::buffered_file f = read_end.fdopen("r"); 41 | if (fp) 42 | *fp = f.get(); 43 | return f; 44 | } 45 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------------------------------- 3 | 4 | // Utilities 5 | @import "mixins/hide-text.less"; 6 | @import "mixins/opacity.less"; 7 | @import "mixins/image.less"; 8 | @import "mixins/labels.less"; 9 | @import "mixins/reset-filter.less"; 10 | @import "mixins/resize.less"; 11 | @import "mixins/responsive-visibility.less"; 12 | @import "mixins/size.less"; 13 | @import "mixins/tab-focus.less"; 14 | @import "mixins/text-emphasis.less"; 15 | @import "mixins/text-overflow.less"; 16 | @import "mixins/vendor-prefixes.less"; 17 | 18 | // Components 19 | @import "mixins/alerts.less"; 20 | @import "mixins/buttons.less"; 21 | @import "mixins/panels.less"; 22 | @import "mixins/pagination.less"; 23 | @import "mixins/list-group.less"; 24 | @import "mixins/nav-divider.less"; 25 | @import "mixins/forms.less"; 26 | @import "mixins/progress-bar.less"; 27 | @import "mixins/table-row.less"; 28 | 29 | // Skins 30 | @import "mixins/background-variant.less"; 31 | @import "mixins/border-radius.less"; 32 | @import "mixins/gradients.less"; 33 | 34 | // Layout 35 | @import "mixins/clearfix.less"; 36 | @import "mixins/center-block.less"; 37 | @import "mixins/nav-vertical-align.less"; 38 | @import "mixins/grid-framework.less"; 39 | @import "mixins/grid.less"; 40 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/buttons.less: -------------------------------------------------------------------------------- 1 | // Button variants 2 | // 3 | // Easily pump out default styles, as well as :hover, :focus, :active, 4 | // and disabled options for all buttons 5 | 6 | .button-variant(@color; @background; @border) { 7 | color: @color; 8 | background-color: @background; 9 | border-color: @border; 10 | 11 | &:hover, 12 | &:focus, 13 | &.focus, 14 | &:active, 15 | &.active, 16 | .open > .dropdown-toggle& { 17 | color: @color; 18 | background-color: darken(@background, 10%); 19 | border-color: darken(@border, 12%); 20 | } 21 | &:active, 22 | &.active, 23 | .open > .dropdown-toggle& { 24 | background-image: none; 25 | } 26 | &.disabled, 27 | &[disabled], 28 | fieldset[disabled] & { 29 | &, 30 | &:hover, 31 | &:focus, 32 | &.focus, 33 | &:active, 34 | &.active { 35 | background-color: @background; 36 | border-color: @border; 37 | } 38 | } 39 | 40 | .badge { 41 | color: @background; 42 | background-color: @color; 43 | } 44 | } 45 | 46 | // Button sizes 47 | .button-size(@padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) { 48 | padding: @padding-vertical @padding-horizontal; 49 | font-size: @font-size; 50 | line-height: @line-height; 51 | border-radius: @border-radius; 52 | } 53 | -------------------------------------------------------------------------------- /doc/bootstrap/bootstrap.less: -------------------------------------------------------------------------------- 1 | // Core variables and mixins 2 | @import "variables.less"; 3 | @import "mixins.less"; 4 | 5 | // Reset and dependencies 6 | @import "normalize.less"; 7 | @import "print.less"; 8 | @import "glyphicons.less"; 9 | 10 | // Core CSS 11 | @import "scaffolding.less"; 12 | @import "type.less"; 13 | @import "code.less"; 14 | @import "grid.less"; 15 | @import "tables.less"; 16 | @import "forms.less"; 17 | @import "buttons.less"; 18 | 19 | // Components 20 | @import "component-animations.less"; 21 | @import "dropdowns.less"; 22 | @import "button-groups.less"; 23 | @import "input-groups.less"; 24 | @import "navs.less"; 25 | @import "navbar.less"; 26 | @import "breadcrumbs.less"; 27 | @import "pagination.less"; 28 | @import "pager.less"; 29 | @import "labels.less"; 30 | @import "badges.less"; 31 | @import "jumbotron.less"; 32 | @import "thumbnails.less"; 33 | @import "alerts.less"; 34 | @import "progress-bars.less"; 35 | @import "media.less"; 36 | @import "list-group.less"; 37 | @import "panels.less"; 38 | @import "responsive-embed.less"; 39 | @import "wells.less"; 40 | @import "close.less"; 41 | 42 | // Components w/ JavaScript 43 | @import "modals.less"; 44 | @import "tooltip.less"; 45 | @import "popovers.less"; 46 | @import "carousel.less"; 47 | 48 | // Utility classes 49 | @import "utilities.less"; 50 | @import "responsive-utilities.less"; 51 | -------------------------------------------------------------------------------- /test/test-main.cc: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - test main function. 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #include 9 | #include "gtest.h" 10 | 11 | #ifdef _WIN32 12 | # include 13 | #endif 14 | 15 | #ifdef _MSC_VER 16 | # include 17 | #else 18 | # define _CrtSetReportFile(a, b) 19 | # define _CrtSetReportMode(a, b) 20 | #endif 21 | 22 | int main(int argc, char **argv) { 23 | #ifdef _WIN32 24 | // Don't display any error dialogs. This also suppresses message boxes 25 | // on assertion failures in MinGW where _set_error_mode/CrtSetReportMode 26 | // doesn't help. 27 | SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | 28 | SEM_NOOPENFILEERRORBOX); 29 | #endif 30 | // Disable message boxes on assertion failures. 31 | _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); 32 | _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); 33 | _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); 34 | _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); 35 | try { 36 | testing::InitGoogleTest(&argc, argv); 37 | return RUN_ALL_TESTS(); 38 | } catch (...) { 39 | // Catch all exceptions to make Coverity happy. 40 | } 41 | return EXIT_FAILURE; 42 | } 43 | -------------------------------------------------------------------------------- /doc/bootstrap/labels.less: -------------------------------------------------------------------------------- 1 | // 2 | // Labels 3 | // -------------------------------------------------- 4 | 5 | .label { 6 | display: inline; 7 | padding: .2em .6em .3em; 8 | font-size: 75%; 9 | font-weight: bold; 10 | line-height: 1; 11 | color: @label-color; 12 | text-align: center; 13 | white-space: nowrap; 14 | vertical-align: baseline; 15 | border-radius: .25em; 16 | 17 | // Add hover effects, but only for links 18 | a& { 19 | &:hover, 20 | &:focus { 21 | color: @label-link-hover-color; 22 | text-decoration: none; 23 | cursor: pointer; 24 | } 25 | } 26 | 27 | // Empty labels collapse automatically (not available in IE8) 28 | &:empty { 29 | display: none; 30 | } 31 | 32 | // Quick fix for labels in buttons 33 | .btn & { 34 | position: relative; 35 | top: -1px; 36 | } 37 | } 38 | 39 | // Colors 40 | // Contextual variations (linked labels get darker on :hover) 41 | 42 | .label-default { 43 | .label-variant(@label-default-bg); 44 | } 45 | 46 | .label-primary { 47 | .label-variant(@label-primary-bg); 48 | } 49 | 50 | .label-success { 51 | .label-variant(@label-success-bg); 52 | } 53 | 54 | .label-info { 55 | .label-variant(@label-info-bg); 56 | } 57 | 58 | .label-warning { 59 | .label-variant(@label-warning-bg); 60 | } 61 | 62 | .label-danger { 63 | .label-variant(@label-danger-bg); 64 | } 65 | -------------------------------------------------------------------------------- /LICENSE.rst: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2016, Victor Zverovich 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /doc/fmt.less: -------------------------------------------------------------------------------- 1 | @import 'bootstrap.less'; 2 | 3 | @header-bg: #094d75; 4 | @icon-font-path: "fonts/"; 5 | 6 | html { 7 | overflow-y: scroll; 8 | } 9 | 10 | .navbar { 11 | border-radius: 0; 12 | margin-bottom: 0; 13 | background-color: darken(@header-bg, 10%); 14 | } 15 | 16 | .jumbotron { 17 | #gradient > .vertical(@header-bg; darken(@header-bg, 2%); 50%; 50%); 18 | background-size: 100% 4px; 19 | background-color: @header-bg; 20 | background-repeat: repeat-y; 21 | color: white; 22 | text-align: center; 23 | } 24 | 25 | div.sphinxsidebar { 26 | margin-left: 0; 27 | } 28 | 29 | // Keep content not too wide for better readability. 30 | .navbar-content, .content { 31 | .make-md-column-offset(1); 32 | .make-md-column(10); 33 | .make-lg-column-offset(2); 34 | .make-lg-column(8); 35 | } 36 | 37 | .footer { 38 | padding-top: 20px; 39 | padding-bottom: 20px; 40 | border-top: 1px solid @gray-lighter; 41 | text-align: center; 42 | } 43 | 44 | // Indent descriptions of classes, functions and macros. 45 | .class dd, .function dd, .macro dd { 46 | margin-left: 20px; 47 | } 48 | 49 | // Remove Bootstrap padding for Sphinx containers. 50 | .breathe-sectiondef.container { 51 | padding: 0; 52 | } 53 | 54 | // Remove Bootstrap padding for Sphinx code elements in API signatures. 55 | .descclassname, .descname { 56 | padding: 0; 57 | } 58 | 59 | p.rubric { 60 | margin-top: 10px; 61 | } 62 | 63 | .github-btn { 64 | border: 0; 65 | overflow: hidden; 66 | } 67 | -------------------------------------------------------------------------------- /doc/bootstrap/badges.less: -------------------------------------------------------------------------------- 1 | // 2 | // Badges 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .badge { 8 | display: inline-block; 9 | min-width: 10px; 10 | padding: 3px 7px; 11 | font-size: @font-size-small; 12 | font-weight: @badge-font-weight; 13 | color: @badge-color; 14 | line-height: @badge-line-height; 15 | vertical-align: baseline; 16 | white-space: nowrap; 17 | text-align: center; 18 | background-color: @badge-bg; 19 | border-radius: @badge-border-radius; 20 | 21 | // Empty badges collapse automatically (not available in IE8) 22 | &:empty { 23 | display: none; 24 | } 25 | 26 | // Quick fix for badges in buttons 27 | .btn & { 28 | position: relative; 29 | top: -1px; 30 | } 31 | 32 | .btn-xs &, 33 | .btn-group-xs > .btn & { 34 | top: 0; 35 | padding: 1px 5px; 36 | } 37 | 38 | // Hover state, but only for links 39 | a& { 40 | &:hover, 41 | &:focus { 42 | color: @badge-link-hover-color; 43 | text-decoration: none; 44 | cursor: pointer; 45 | } 46 | } 47 | 48 | // Account for badges in navs 49 | .list-group-item.active > &, 50 | .nav-pills > .active > a > & { 51 | color: @badge-active-color; 52 | background-color: @badge-active-bg; 53 | } 54 | 55 | .list-group-item > & { 56 | float: right; 57 | } 58 | 59 | .list-group-item > & + & { 60 | margin-right: 5px; 61 | } 62 | 63 | .nav-pills > li > a > & { 64 | margin-left: 3px; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /support/appveyor-build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Build the project on AppVeyor. 3 | 4 | import os 5 | from subprocess import check_call 6 | 7 | build = os.environ['BUILD'] 8 | config = os.environ['CONFIGURATION'] 9 | platform = os.environ['PLATFORM'] 10 | path = os.environ['PATH'] 11 | image = os.environ['APPVEYOR_BUILD_WORKER_IMAGE'] 12 | jobid = os.environ['APPVEYOR_JOB_ID'] 13 | cmake_command = ['cmake', '-DFMT_PEDANTIC=ON', '-DCMAKE_BUILD_TYPE=' + config, '..'] 14 | if build == 'mingw': 15 | cmake_command.append('-GMinGW Makefiles') 16 | build_command = ['mingw32-make', '-j4'] 17 | test_command = ['mingw32-make', 'test'] 18 | # Remove the path to Git bin directory from $PATH because it breaks 19 | # MinGW config. 20 | path = path.replace(r'C:\Program Files (x86)\Git\bin', '') 21 | os.environ['PATH'] = r'C:\MinGW\bin;' + path 22 | else: 23 | # Add MSBuild 14.0 to PATH as described in 24 | # http://help.appveyor.com/discussions/problems/2229-v140-not-found-on-vs2105rc. 25 | os.environ['PATH'] = r'C:\Program Files (x86)\MSBuild\15.0\Bin;' + path 26 | if image == 'Visual Studio 2013': 27 | generator = 'Visual Studio 12 2013' 28 | elif image == 'Visual Studio 2015': 29 | generator = 'Visual Studio 14 2015' 30 | elif image == 'Visual Studio 2017': 31 | generator = 'Visual Studio 15 2017' 32 | if platform == 'x64': 33 | generator += ' Win64' 34 | cmake_command.append('-G' + generator) 35 | build_command = ['cmake', '--build', '.', '--config', config, '--', '/m:4'] 36 | test_command = ['ctest', '-C', config] 37 | 38 | check_call(cmake_command) 39 | check_call(build_command) 40 | check_call(test_command) 41 | -------------------------------------------------------------------------------- /doc/bootstrap/code.less: -------------------------------------------------------------------------------- 1 | // 2 | // Code (inline and block) 3 | // -------------------------------------------------- 4 | 5 | 6 | // Inline and block code styles 7 | code, 8 | kbd, 9 | pre, 10 | samp { 11 | font-family: @font-family-monospace; 12 | } 13 | 14 | // Inline code 15 | code { 16 | padding: 2px 4px; 17 | font-size: 90%; 18 | color: @code-color; 19 | background-color: @code-bg; 20 | border-radius: @border-radius-base; 21 | } 22 | 23 | // User input typically entered via keyboard 24 | kbd { 25 | padding: 2px 4px; 26 | font-size: 90%; 27 | color: @kbd-color; 28 | background-color: @kbd-bg; 29 | border-radius: @border-radius-small; 30 | box-shadow: inset 0 -1px 0 rgba(0,0,0,.25); 31 | 32 | kbd { 33 | padding: 0; 34 | font-size: 100%; 35 | font-weight: bold; 36 | box-shadow: none; 37 | } 38 | } 39 | 40 | // Blocks of code 41 | pre { 42 | display: block; 43 | padding: ((@line-height-computed - 1) / 2); 44 | margin: 0 0 (@line-height-computed / 2); 45 | font-size: (@font-size-base - 1); // 14px to 13px 46 | line-height: @line-height-base; 47 | word-break: break-all; 48 | word-wrap: break-word; 49 | color: @pre-color; 50 | background-color: @pre-bg; 51 | border: 1px solid @pre-border-color; 52 | border-radius: @border-radius-base; 53 | 54 | // Account for some code outputs that place code tags in pre tags 55 | code { 56 | padding: 0; 57 | font-size: inherit; 58 | color: inherit; 59 | white-space: pre-wrap; 60 | background-color: transparent; 61 | border-radius: 0; 62 | } 63 | } 64 | 65 | // Enable scrollable blocks of code 66 | .pre-scrollable { 67 | max-height: @pre-scrollable-max-height; 68 | overflow-y: scroll; 69 | } 70 | -------------------------------------------------------------------------------- /test/time-test.cc: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - time formatting tests 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #ifdef WIN32 9 | #define _CRT_SECURE_NO_WARNINGS 10 | #endif 11 | 12 | #include "gmock.h" 13 | #include "fmt/time.h" 14 | 15 | TEST(TimeTest, Format) { 16 | std::tm tm = std::tm(); 17 | tm.tm_year = 116; 18 | tm.tm_mon = 3; 19 | tm.tm_mday = 25; 20 | EXPECT_EQ("The date is 2016-04-25.", 21 | fmt::format("The date is {:%Y-%m-%d}.", tm)); 22 | } 23 | 24 | TEST(TimeTest, GrowBuffer) { 25 | std::string s = "{:"; 26 | for (int i = 0; i < 30; ++i) 27 | s += "%c"; 28 | s += "}\n"; 29 | std::time_t t = std::time(nullptr); 30 | fmt::format(s, *std::localtime(&t)); 31 | } 32 | 33 | TEST(TimeTest, EmptyResult) { 34 | EXPECT_EQ("", fmt::format("{}", std::tm())); 35 | } 36 | 37 | static bool EqualTime(const std::tm &lhs, const std::tm &rhs) { 38 | return lhs.tm_sec == rhs.tm_sec && 39 | lhs.tm_min == rhs.tm_min && 40 | lhs.tm_hour == rhs.tm_hour && 41 | lhs.tm_mday == rhs.tm_mday && 42 | lhs.tm_mon == rhs.tm_mon && 43 | lhs.tm_year == rhs.tm_year && 44 | lhs.tm_wday == rhs.tm_wday && 45 | lhs.tm_yday == rhs.tm_yday && 46 | lhs.tm_isdst == rhs.tm_isdst; 47 | } 48 | 49 | TEST(TimeTest, LocalTime) { 50 | std::time_t t = std::time(nullptr); 51 | std::tm tm = *std::localtime(&t); 52 | EXPECT_TRUE(EqualTime(tm, fmt::localtime(t))); 53 | } 54 | 55 | TEST(TimeTest, GMTime) { 56 | std::time_t t = std::time(nullptr); 57 | std::tm tm = *std::gmtime(&t); 58 | EXPECT_TRUE(EqualTime(tm, fmt::gmtime(t))); 59 | } 60 | -------------------------------------------------------------------------------- /test/mock-allocator.h: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - mock allocator 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #ifndef FMT_MOCK_ALLOCATOR_H_ 9 | #define FMT_MOCK_ALLOCATOR_H_ 10 | 11 | #include "gmock.h" 12 | #include "fmt/format.h" 13 | 14 | template 15 | class mock_allocator { 16 | public: 17 | mock_allocator() {} 18 | mock_allocator(const mock_allocator &) {} 19 | typedef T value_type; 20 | MOCK_METHOD1_T(allocate, T* (std::size_t n)); 21 | MOCK_METHOD2_T(deallocate, void (T* p, std::size_t n)); 22 | }; 23 | 24 | template 25 | class allocator_ref { 26 | private: 27 | Allocator *alloc_; 28 | 29 | void move(allocator_ref &other) { 30 | alloc_ = other.alloc_; 31 | other.alloc_ = nullptr; 32 | } 33 | 34 | public: 35 | typedef typename Allocator::value_type value_type; 36 | 37 | explicit allocator_ref(Allocator *alloc = nullptr) : alloc_(alloc) {} 38 | 39 | allocator_ref(const allocator_ref &other) : alloc_(other.alloc_) {} 40 | allocator_ref(allocator_ref &&other) { move(other); } 41 | 42 | allocator_ref& operator=(allocator_ref &&other) { 43 | assert(this != &other); 44 | move(other); 45 | return *this; 46 | } 47 | 48 | allocator_ref& operator=(const allocator_ref &other) { 49 | alloc_ = other.alloc_; 50 | return *this; 51 | } 52 | 53 | public: 54 | Allocator *get() const { return alloc_; } 55 | 56 | value_type* allocate(std::size_t n) { 57 | return fmt::internal::allocate(*alloc_, n); 58 | } 59 | void deallocate(value_type* p, std::size_t n) { alloc_->deallocate(p, n); } 60 | }; 61 | 62 | #endif // FMT_MOCK_ALLOCATOR_H_ 63 | -------------------------------------------------------------------------------- /test/posix-mock.h: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - mocks of POSIX functions 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #ifndef FMT_POSIX_TEST_H 9 | #define FMT_POSIX_TEST_H 10 | 11 | #include 12 | #include 13 | 14 | #ifdef _WIN32 15 | # include 16 | #else 17 | # include // for FreeBSD version 18 | # include // for ssize_t 19 | #endif 20 | 21 | #ifndef _MSC_VER 22 | struct stat; 23 | #endif 24 | 25 | namespace test { 26 | 27 | #ifndef _MSC_VER 28 | // Size type for read and write. 29 | typedef size_t size_t; 30 | typedef ssize_t ssize_t; 31 | int open(const char *path, int oflag, int mode); 32 | int fstat(int fd, struct stat *buf); 33 | #else 34 | typedef unsigned size_t; 35 | typedef int ssize_t; 36 | errno_t sopen_s( 37 | int* pfh, const char *filename, int oflag, int shflag, int pmode); 38 | #endif 39 | 40 | #ifndef _WIN32 41 | long sysconf(int name); 42 | #else 43 | DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh); 44 | #endif 45 | 46 | int close(int fildes); 47 | 48 | int dup(int fildes); 49 | int dup2(int fildes, int fildes2); 50 | 51 | FILE *fdopen(int fildes, const char *mode); 52 | 53 | ssize_t read(int fildes, void *buf, size_t nbyte); 54 | ssize_t write(int fildes, const void *buf, size_t nbyte); 55 | 56 | #ifndef _WIN32 57 | int pipe(int fildes[2]); 58 | #else 59 | int pipe(int *pfds, unsigned psize, int textmode); 60 | #endif 61 | 62 | FILE *fopen(const char *filename, const char *mode); 63 | int fclose(FILE *stream); 64 | int (fileno)(FILE *stream); 65 | } // namespace test 66 | 67 | #define FMT_SYSTEM(call) test::call 68 | 69 | #endif // FMT_POSIX_TEST_H 70 | -------------------------------------------------------------------------------- /doc/bootstrap/grid.less: -------------------------------------------------------------------------------- 1 | // 2 | // Grid system 3 | // -------------------------------------------------- 4 | 5 | 6 | // Container widths 7 | // 8 | // Set the container width, and override it for fixed navbars in media queries. 9 | 10 | .tb-container { 11 | .container-fixed(); 12 | 13 | @media (min-width: @screen-sm-min) { 14 | width: @container-sm; 15 | } 16 | @media (min-width: @screen-md-min) { 17 | width: @container-md; 18 | } 19 | @media (min-width: @screen-lg-min) { 20 | width: @container-lg; 21 | } 22 | } 23 | 24 | 25 | // Fluid container 26 | // 27 | // Utilizes the mixin meant for fixed width containers, but without any defined 28 | // width for fluid, full width layouts. 29 | 30 | .container-fluid { 31 | .container-fixed(); 32 | } 33 | 34 | 35 | // Row 36 | // 37 | // Rows contain and clear the floats of your columns. 38 | 39 | .row { 40 | .make-row(); 41 | } 42 | 43 | 44 | // Columns 45 | // 46 | // Common styles for small and large grid columns 47 | 48 | .make-grid-columns(); 49 | 50 | 51 | // Extra small grid 52 | // 53 | // Columns, offsets, pushes, and pulls for extra small devices like 54 | // smartphones. 55 | 56 | .make-grid(xs); 57 | 58 | 59 | // Small grid 60 | // 61 | // Columns, offsets, pushes, and pulls for the small device range, from phones 62 | // to tablets. 63 | 64 | @media (min-width: @screen-sm-min) { 65 | .make-grid(sm); 66 | } 67 | 68 | 69 | // Medium grid 70 | // 71 | // Columns, offsets, pushes, and pulls for the desktop device range. 72 | 73 | @media (min-width: @screen-md-min) { 74 | .make-grid(md); 75 | } 76 | 77 | 78 | // Large grid 79 | // 80 | // Columns, offsets, pushes, and pulls for the large desktop device range. 81 | 82 | @media (min-width: @screen-lg-min) { 83 | .make-grid(lg); 84 | } 85 | -------------------------------------------------------------------------------- /src/format.cc: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ 2 | // 3 | // Copyright (c) 2012 - 2016, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #include "fmt/format-inl.h" 9 | 10 | FMT_BEGIN_NAMESPACE 11 | template struct internal::basic_data; 12 | 13 | // Explicit instantiations for char. 14 | 15 | template FMT_API char internal::thousands_sep(locale_provider *lp); 16 | 17 | template void internal::basic_buffer::append(const char *, const char *); 18 | 19 | template void internal::arg_map::init( 20 | const basic_format_args &args); 21 | 22 | template FMT_API int internal::char_traits::format_float( 23 | char *, std::size_t, const char *, int, double); 24 | 25 | template FMT_API int internal::char_traits::format_float( 26 | char *, std::size_t, const char *, int, long double); 27 | 28 | template FMT_API std::string internal::vformat( 29 | string_view, basic_format_args); 30 | 31 | // Explicit instantiations for wchar_t. 32 | 33 | template FMT_API wchar_t internal::thousands_sep(locale_provider *); 34 | 35 | template void internal::basic_buffer::append( 36 | const wchar_t *, const wchar_t *); 37 | 38 | template void internal::arg_map::init( 39 | const basic_format_args &); 40 | 41 | template FMT_API int internal::char_traits::format_float( 42 | wchar_t *, std::size_t, const wchar_t *, int, double); 43 | 44 | template FMT_API int internal::char_traits::format_float( 45 | wchar_t *, std::size_t, const wchar_t *, int, long double); 46 | 47 | template FMT_API std::wstring internal::vformat( 48 | wstring_view, basic_format_args); 49 | FMT_END_NAMESPACE 50 | -------------------------------------------------------------------------------- /test/custom-formatter-test.cc: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - custom argument formatter tests 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #include "fmt/format.h" 9 | #include "gtest-extra.h" 10 | 11 | // MSVC 2013 is known to be broken. 12 | #if !FMT_MSC_VER || FMT_MSC_VER > 1800 13 | 14 | // A custom argument formatter that doesn't print `-` for floating-point values 15 | // rounded to 0. 16 | class custom_arg_formatter : 17 | public fmt::arg_formatter> { 18 | public: 19 | typedef fmt::back_insert_range range; 20 | typedef fmt::arg_formatter base; 21 | 22 | custom_arg_formatter( 23 | fmt::format_context &ctx, fmt::format_specs *s = FMT_NULL) 24 | : base(ctx, s) {} 25 | 26 | using base::operator(); 27 | 28 | iterator operator()(double value) { 29 | // Comparing a float to 0.0 is safe. 30 | if (round(value * pow(10, spec()->precision)) == 0.0) 31 | value = 0; 32 | return base::operator()(value); 33 | } 34 | }; 35 | 36 | std::string custom_vformat(fmt::string_view format_str, fmt::format_args args) { 37 | fmt::memory_buffer buffer; 38 | // Pass custom argument formatter as a template arg to vwrite. 39 | fmt::vformat_to(buffer, format_str, args); 40 | return std::string(buffer.data(), buffer.size()); 41 | } 42 | 43 | template 44 | std::string custom_format(const char *format_str, const Args & ... args) { 45 | auto va = fmt::make_format_args(args...); 46 | return custom_vformat(format_str, va); 47 | } 48 | 49 | TEST(CustomFormatterTest, Format) { 50 | EXPECT_EQ("0.00", custom_format("{:.2f}", -.00001)); 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /support/compute-powers.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Compute 10 ** exp with exp in the range [min_exponent, max_exponent] and print 3 | # normalized (with most-significant bit equal to 1) significands in hexadecimal. 4 | 5 | from __future__ import print_function 6 | 7 | min_exponent = -348 8 | max_exponent = 340 9 | step = 8 10 | significand_size = 64 11 | exp_offset = 2000 12 | 13 | class fp: 14 | pass 15 | 16 | powers = [] 17 | for i, exp in enumerate(range(min_exponent, max_exponent + 1, step)): 18 | result = fp() 19 | n = 10 ** exp if exp >= 0 else 2 ** exp_offset / 10 ** -exp 20 | k = significand_size + 1 21 | # Convert to binary and round. 22 | binary = '{:b}'.format(n) 23 | result.f = (int('{:0<{}}'.format(binary[:k], k), 2) + 1) / 2 24 | result.e = len(binary) - (exp_offset if exp < 0 else 0) - significand_size 25 | powers.append(result) 26 | # Sanity check. 27 | exp_offset10 = 400 28 | actual = result.f * 10 ** exp_offset10 29 | if result.e > 0: 30 | actual *= 2 ** result.e 31 | else: 32 | for j in range(-result.e): 33 | actual /= 2 34 | expected = 10 ** (exp_offset10 + exp) 35 | precision = len('{}'.format(expected)) - len('{}'.format(actual - expected)) 36 | if precision < 19: 37 | print('low precision:', precision) 38 | exit(1) 39 | 40 | print('Significands:', end='') 41 | for i, fp in enumerate(powers): 42 | if i % 3 == 0: 43 | print(end='\n ') 44 | print(' {:0<#16x}'.format(fp.f, ), end=',') 45 | 46 | print('\n\nExponents:', end='') 47 | for i, fp in enumerate(powers): 48 | if i % 11 == 0: 49 | print(end='\n ') 50 | print(' {:5}'.format(fp.e), end=',') 51 | 52 | print('\n\nMax exponent difference:', 53 | max([x.e - powers[i - 1].e for i, x in enumerate(powers)][1:])) 54 | -------------------------------------------------------------------------------- /doc/bootstrap/alerts.less: -------------------------------------------------------------------------------- 1 | // 2 | // Alerts 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base styles 7 | // ------------------------- 8 | 9 | .alert { 10 | padding: @alert-padding; 11 | margin-bottom: @line-height-computed; 12 | border: 1px solid transparent; 13 | border-radius: @alert-border-radius; 14 | 15 | // Headings for larger alerts 16 | h4 { 17 | margin-top: 0; 18 | // Specified for the h4 to prevent conflicts of changing @headings-color 19 | color: inherit; 20 | } 21 | 22 | // Provide class for links that match alerts 23 | .alert-link { 24 | font-weight: @alert-link-font-weight; 25 | } 26 | 27 | // Improve alignment and spacing of inner content 28 | > p, 29 | > ul { 30 | margin-bottom: 0; 31 | } 32 | 33 | > p + p { 34 | margin-top: 5px; 35 | } 36 | } 37 | 38 | // Dismissible alerts 39 | // 40 | // Expand the right padding and account for the close button's positioning. 41 | 42 | .alert-dismissable, // The misspelled .alert-dismissable was deprecated in 3.2.0. 43 | .alert-dismissible { 44 | padding-right: (@alert-padding + 20); 45 | 46 | // Adjust close link position 47 | .close { 48 | position: relative; 49 | top: -2px; 50 | right: -21px; 51 | color: inherit; 52 | } 53 | } 54 | 55 | // Alternate styles 56 | // 57 | // Generate contextual modifier classes for colorizing the alert. 58 | 59 | .alert-success { 60 | .alert-variant(@alert-success-bg; @alert-success-border; @alert-success-text); 61 | } 62 | 63 | .alert-info { 64 | .alert-variant(@alert-info-bg; @alert-info-border; @alert-info-text); 65 | } 66 | 67 | .alert-warning { 68 | .alert-variant(@alert-warning-bg; @alert-warning-border; @alert-warning-text); 69 | } 70 | 71 | .alert-danger { 72 | .alert-variant(@alert-danger-bg; @alert-danger-border; @alert-danger-text); 73 | } 74 | -------------------------------------------------------------------------------- /doc/_templates/search.html: -------------------------------------------------------------------------------- 1 | {# 2 | basic/search.html 3 | ~~~~~~~~~~~~~~~~~ 4 | 5 | Template for the search page. 6 | 7 | :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | #} 10 | {%- extends "layout.html" %} 11 | {% set title = _('Search') %} 12 | {% set script_files = script_files + ['_static/searchtools.js'] %} 13 | {% block extrahead %} 14 | 17 | {# this is used when loading the search index using $.ajax fails, 18 | such as on Chrome for documents on localhost #} 19 | 20 | {{ super() }} 21 | {% endblock %} 22 | {% block body %} 23 |

{{ _('Search') }}

24 |
25 | 26 |

27 | {% trans %}Please activate JavaScript to enable the search 28 | functionality.{% endtrans %} 29 |

30 |
31 |

32 | {% trans %}From here you can search these documents. Enter your search 33 | words into the box below and click "search". Note that the search 34 | function will automatically search for all of the words. Pages 35 | containing fewer words won't appear in the result list.{% endtrans %} 36 |

37 | {{ searchform('form-inline', True) }} 38 | {% if search_performed %} 39 |

{{ _('Search Results') }}

40 | {% if not search_results %} 41 |

{{ _('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.') }}

42 | {% endif %} 43 | {% endif %} 44 |
45 | {% if search_results %} 46 |
    47 | {% for href, caption, context in search_results %} 48 |
  • {{ caption }} 49 |
    {{ context|e }}
    50 |
  • 51 | {% endfor %} 52 |
53 | {% endif %} 54 |
55 | {% endblock %} 56 | -------------------------------------------------------------------------------- /doc/bootstrap/progress-bars.less: -------------------------------------------------------------------------------- 1 | // 2 | // Progress bars 3 | // -------------------------------------------------- 4 | 5 | 6 | // Bar animations 7 | // ------------------------- 8 | 9 | // WebKit 10 | @-webkit-keyframes progress-bar-stripes { 11 | from { background-position: 40px 0; } 12 | to { background-position: 0 0; } 13 | } 14 | 15 | // Spec and IE10+ 16 | @keyframes progress-bar-stripes { 17 | from { background-position: 40px 0; } 18 | to { background-position: 0 0; } 19 | } 20 | 21 | 22 | // Bar itself 23 | // ------------------------- 24 | 25 | // Outer container 26 | .progress { 27 | overflow: hidden; 28 | height: @line-height-computed; 29 | margin-bottom: @line-height-computed; 30 | background-color: @progress-bg; 31 | border-radius: @progress-border-radius; 32 | .box-shadow(inset 0 1px 2px rgba(0,0,0,.1)); 33 | } 34 | 35 | // Bar of progress 36 | .progress-bar { 37 | float: left; 38 | width: 0%; 39 | height: 100%; 40 | font-size: @font-size-small; 41 | line-height: @line-height-computed; 42 | color: @progress-bar-color; 43 | text-align: center; 44 | background-color: @progress-bar-bg; 45 | .box-shadow(inset 0 -1px 0 rgba(0,0,0,.15)); 46 | .transition(width .6s ease); 47 | } 48 | 49 | // Striped bars 50 | // 51 | // `.progress-striped .progress-bar` is deprecated as of v3.2.0 in favor of the 52 | // `.progress-bar-striped` class, which you just add to an existing 53 | // `.progress-bar`. 54 | .progress-striped .progress-bar, 55 | .progress-bar-striped { 56 | #gradient > .striped(); 57 | background-size: 40px 40px; 58 | } 59 | 60 | // Call animation for the active one 61 | // 62 | // `.progress.active .progress-bar` is deprecated as of v3.2.0 in favor of the 63 | // `.progress-bar.active` approach. 64 | .progress.active .progress-bar, 65 | .progress-bar.active { 66 | .animation(progress-bar-stripes 2s linear infinite); 67 | } 68 | 69 | 70 | // Variations 71 | // ------------------------- 72 | 73 | .progress-bar-success { 74 | .progress-bar-variant(@progress-bar-success-bg); 75 | } 76 | 77 | .progress-bar-info { 78 | .progress-bar-variant(@progress-bar-info-bg); 79 | } 80 | 81 | .progress-bar-warning { 82 | .progress-bar-variant(@progress-bar-warning-bg); 83 | } 84 | 85 | .progress-bar-danger { 86 | .progress-bar-variant(@progress-bar-danger-bg); 87 | } 88 | -------------------------------------------------------------------------------- /test/util.h: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - test utilities 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "fmt/posix.h" 13 | 14 | enum {BUFFER_SIZE = 256}; 15 | 16 | #ifdef _MSC_VER 17 | # define FMT_VSNPRINTF vsprintf_s 18 | #else 19 | # define FMT_VSNPRINTF vsnprintf 20 | #endif 21 | 22 | template 23 | void safe_sprintf(char (&buffer)[SIZE], const char *format, ...) { 24 | std::va_list args; 25 | va_start(args, format); 26 | FMT_VSNPRINTF(buffer, SIZE, format, args); 27 | va_end(args); 28 | } 29 | 30 | // Increment a number in a string. 31 | void increment(char *s); 32 | 33 | std::string get_system_error(int error_code); 34 | 35 | extern const char *const FILE_CONTENT; 36 | 37 | // Opens a buffered file for reading. 38 | fmt::buffered_file open_buffered_file(FILE **fp = nullptr); 39 | 40 | inline FILE *safe_fopen(const char *filename, const char *mode) { 41 | #if defined(_WIN32) && !defined(__MINGW32__) 42 | // Fix MSVC warning about "unsafe" fopen. 43 | FILE *f = 0; 44 | errno = fopen_s(&f, filename, mode); 45 | return f; 46 | #else 47 | return std::fopen(filename, mode); 48 | #endif 49 | } 50 | 51 | template 52 | class BasicTestString { 53 | private: 54 | std::basic_string value_; 55 | 56 | static const Char EMPTY[]; 57 | 58 | public: 59 | explicit BasicTestString(const Char *value = EMPTY) : value_(value) {} 60 | 61 | const std::basic_string &value() const { return value_; } 62 | }; 63 | 64 | template 65 | const Char BasicTestString::EMPTY[] = {0}; 66 | 67 | typedef BasicTestString TestString; 68 | typedef BasicTestString TestWString; 69 | 70 | template 71 | std::basic_ostream &operator<<( 72 | std::basic_ostream &os, const BasicTestString &s) { 73 | os << s.value(); 74 | return os; 75 | } 76 | 77 | class Date { 78 | int year_, month_, day_; 79 | public: 80 | Date(int year, int month, int day) : year_(year), month_(month), day_(day) {} 81 | 82 | int year() const { return year_; } 83 | int month() const { return month_; } 84 | int day() const { return day_; } 85 | }; 86 | -------------------------------------------------------------------------------- /doc/bootstrap/pagination.less: -------------------------------------------------------------------------------- 1 | // 2 | // Pagination (multiple pages) 3 | // -------------------------------------------------- 4 | .pagination { 5 | display: inline-block; 6 | padding-left: 0; 7 | margin: @line-height-computed 0; 8 | border-radius: @border-radius-base; 9 | 10 | > li { 11 | display: inline; // Remove list-style and block-level defaults 12 | > a, 13 | > span { 14 | position: relative; 15 | float: left; // Collapse white-space 16 | padding: @padding-base-vertical @padding-base-horizontal; 17 | line-height: @line-height-base; 18 | text-decoration: none; 19 | color: @pagination-color; 20 | background-color: @pagination-bg; 21 | border: 1px solid @pagination-border; 22 | margin-left: -1px; 23 | } 24 | &:first-child { 25 | > a, 26 | > span { 27 | margin-left: 0; 28 | .border-left-radius(@border-radius-base); 29 | } 30 | } 31 | &:last-child { 32 | > a, 33 | > span { 34 | .border-right-radius(@border-radius-base); 35 | } 36 | } 37 | } 38 | 39 | > li > a, 40 | > li > span { 41 | &:hover, 42 | &:focus { 43 | color: @pagination-hover-color; 44 | background-color: @pagination-hover-bg; 45 | border-color: @pagination-hover-border; 46 | } 47 | } 48 | 49 | > .active > a, 50 | > .active > span { 51 | &, 52 | &:hover, 53 | &:focus { 54 | z-index: 2; 55 | color: @pagination-active-color; 56 | background-color: @pagination-active-bg; 57 | border-color: @pagination-active-border; 58 | cursor: default; 59 | } 60 | } 61 | 62 | > .disabled { 63 | > span, 64 | > span:hover, 65 | > span:focus, 66 | > a, 67 | > a:hover, 68 | > a:focus { 69 | color: @pagination-disabled-color; 70 | background-color: @pagination-disabled-bg; 71 | border-color: @pagination-disabled-border; 72 | cursor: @cursor-disabled; 73 | } 74 | } 75 | } 76 | 77 | // Sizing 78 | // -------------------------------------------------- 79 | 80 | // Large 81 | .pagination-lg { 82 | .pagination-size(@padding-large-vertical; @padding-large-horizontal; @font-size-large; @border-radius-large); 83 | } 84 | 85 | // Small 86 | .pagination-sm { 87 | .pagination-size(@padding-small-vertical; @padding-small-horizontal; @font-size-small; @border-radius-small); 88 | } 89 | -------------------------------------------------------------------------------- /test/gtest-extra.cc: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - custom Google Test assertions 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #include "gtest-extra.h" 9 | 10 | #if FMT_USE_FILE_DESCRIPTORS 11 | 12 | using fmt::file; 13 | 14 | void OutputRedirect::flush() { 15 | #if EOF != -1 16 | # error "FMT_RETRY assumes return value of -1 indicating failure" 17 | #endif 18 | int result = 0; 19 | FMT_RETRY(result, fflush(file_)); 20 | if (result != 0) 21 | throw fmt::system_error(errno, "cannot flush stream"); 22 | } 23 | 24 | void OutputRedirect::restore() { 25 | if (original_.descriptor() == -1) 26 | return; // Already restored. 27 | flush(); 28 | // Restore the original file. 29 | original_.dup2(FMT_POSIX(fileno(file_))); 30 | original_.close(); 31 | } 32 | 33 | OutputRedirect::OutputRedirect(FILE *f) : file_(f) { 34 | flush(); 35 | int fd = FMT_POSIX(fileno(f)); 36 | // Create a file object referring to the original file. 37 | original_ = file::dup(fd); 38 | // Create a pipe. 39 | file write_end; 40 | file::pipe(read_end_, write_end); 41 | // Connect the passed FILE object to the write end of the pipe. 42 | write_end.dup2(fd); 43 | } 44 | 45 | OutputRedirect::~OutputRedirect() FMT_NOEXCEPT { 46 | try { 47 | restore(); 48 | } catch (const std::exception &e) { 49 | std::fputs(e.what(), stderr); 50 | } 51 | } 52 | 53 | std::string OutputRedirect::restore_and_read() { 54 | // Restore output. 55 | restore(); 56 | 57 | // Read everything from the pipe. 58 | std::string content; 59 | if (read_end_.descriptor() == -1) 60 | return content; // Already read. 61 | enum { BUFFER_SIZE = 4096 }; 62 | char buffer[BUFFER_SIZE]; 63 | std::size_t count = 0; 64 | do { 65 | count = read_end_.read(buffer, BUFFER_SIZE); 66 | content.append(buffer, count); 67 | } while (count != 0); 68 | read_end_.close(); 69 | return content; 70 | } 71 | 72 | std::string read(file &f, std::size_t count) { 73 | std::string buffer(count, '\0'); 74 | std::size_t n = 0, offset = 0; 75 | do { 76 | n = f.read(&buffer[offset], count - offset); 77 | // We can't read more than size_t bytes since count has type size_t. 78 | offset += n; 79 | } while (offset < count && n != 0); 80 | buffer.resize(offset); 81 | return buffer; 82 | } 83 | 84 | #endif // FMT_USE_FILE_DESCRIPTORS 85 | 86 | std::string format_system_error(int error_code, fmt::string_view message) { 87 | fmt::memory_buffer out; 88 | format_system_error(out, error_code, message); 89 | return to_string(out); 90 | } 91 | -------------------------------------------------------------------------------- /doc/bootstrap/print.less: -------------------------------------------------------------------------------- 1 | /*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */ 2 | 3 | // ========================================================================== 4 | // Print styles. 5 | // Inlined to avoid the additional HTTP request: h5bp.com/r 6 | // ========================================================================== 7 | 8 | @media print { 9 | *, 10 | *:before, 11 | *:after { 12 | background: transparent !important; 13 | color: #000 !important; // Black prints faster: h5bp.com/s 14 | box-shadow: none !important; 15 | text-shadow: none !important; 16 | } 17 | 18 | a, 19 | a:visited { 20 | text-decoration: underline; 21 | } 22 | 23 | a[href]:after { 24 | content: " (" attr(href) ")"; 25 | } 26 | 27 | abbr[title]:after { 28 | content: " (" attr(title) ")"; 29 | } 30 | 31 | // Don't show links that are fragment identifiers, 32 | // or use the `javascript:` pseudo protocol 33 | a[href^="#"]:after, 34 | a[href^="javascript:"]:after { 35 | content: ""; 36 | } 37 | 38 | pre, 39 | blockquote { 40 | border: 1px solid #999; 41 | page-break-inside: avoid; 42 | } 43 | 44 | thead { 45 | display: table-header-group; // h5bp.com/t 46 | } 47 | 48 | tr, 49 | img { 50 | page-break-inside: avoid; 51 | } 52 | 53 | img { 54 | max-width: 100% !important; 55 | } 56 | 57 | p, 58 | h2, 59 | h3 { 60 | orphans: 3; 61 | widows: 3; 62 | } 63 | 64 | h2, 65 | h3 { 66 | page-break-after: avoid; 67 | } 68 | 69 | // Bootstrap specific changes start 70 | // 71 | // Chrome (OSX) fix for https://github.com/twbs/bootstrap/issues/11245 72 | // Once fixed, we can just straight up remove this. 73 | select { 74 | background: #fff !important; 75 | } 76 | 77 | // Bootstrap components 78 | .navbar { 79 | display: none; 80 | } 81 | .btn, 82 | .dropup > .btn { 83 | > .caret { 84 | border-top-color: #000 !important; 85 | } 86 | } 87 | .label { 88 | border: 1px solid #000; 89 | } 90 | 91 | .table { 92 | border-collapse: collapse !important; 93 | 94 | td, 95 | th { 96 | background-color: #fff !important; 97 | } 98 | } 99 | .table-bordered { 100 | th, 101 | td { 102 | border: 1px solid #ddd !important; 103 | } 104 | } 105 | 106 | // Bootstrap specific changes end 107 | } 108 | -------------------------------------------------------------------------------- /test/compile-test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Test if compile errors are produced where necessary. 2 | 3 | cmake_minimum_required(VERSION 3.1.0) 4 | 5 | include(CheckCXXSourceCompiles) 6 | include(CheckCXXCompilerFlag) 7 | 8 | set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../../include) 9 | set(CMAKE_REQUIRED_FLAGS ${CXX_STANDARD_FLAG} ${PEDANTIC_COMPILE_FLAGS}) 10 | 11 | function (generate_source result fragment) 12 | set(${result} " 13 | #define FMT_HEADER_ONLY 1 14 | #include \"fmt/format.h\" 15 | int main() { 16 | ${fragment} 17 | } 18 | " PARENT_SCOPE) 19 | endfunction () 20 | 21 | function (expect_compile code) 22 | generate_source(source "${code}") 23 | check_cxx_source_compiles("${source}" compiles) 24 | if (NOT compiles) 25 | set(error_msg "Compile error for: ${code}") 26 | endif () 27 | # Unset the CMake cache variable compiles. Otherwise the compile test will 28 | # just use cached information next time it runs. 29 | unset(compiles CACHE) 30 | if (error_msg) 31 | message(FATAL_ERROR ${error_msg}) 32 | endif () 33 | endfunction () 34 | 35 | function (expect_compile_error code) 36 | generate_source(source "${code}") 37 | check_cxx_source_compiles("${source}" compiles) 38 | if (compiles) 39 | set(error_msg "No compile error for: ${code}") 40 | endif () 41 | # Unset the CMake cache variable compiles. Otherwise the compile test will 42 | # just use cached information next time it runs. 43 | unset(compiles CACHE) 44 | if (error_msg) 45 | message(FATAL_ERROR ${error_msg}) 46 | endif () 47 | endfunction () 48 | 49 | # check if the source file skeleton compiles 50 | expect_compile("") 51 | 52 | # Formatting a wide character with a narrow format string is forbidden. 53 | expect_compile_error("fmt::format(\"{}\", L'a');") 54 | 55 | # Formatting a wide string with a narrow format string is forbidden. 56 | expect_compile_error("fmt::format(\"{}\", L\"foo\");") 57 | 58 | # Formatting a narrow string with a wide format string is forbidden because 59 | # mixing UTF-8 with UTF-16/32 can result in an invalid output. 60 | expect_compile_error("fmt::format(L\"{}\", \"foo\");") 61 | 62 | # Formatting a wide string with a narrow format string is forbidden. 63 | expect_compile_error(" 64 | struct S { 65 | operator std::string() const { return std::string(); } 66 | }; 67 | fmt::format(\"{}\", S()); 68 | ") 69 | 70 | # Make sure that compiler features detected in the header 71 | # match the features detected in CMake. 72 | if (SUPPORTS_USER_DEFINED_LITERALS) 73 | set(supports_udl 1) 74 | else () 75 | set(supports_udl 0) 76 | endif () 77 | expect_compile("#if FMT_USE_USER_DEFINED_LITERALS != ${supports_udl} 78 | # error 79 | #endif") 80 | -------------------------------------------------------------------------------- /test/ranges-test.cc: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - the core API 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | // 8 | // Copyright (c) 2018 - present, Remotion (Igor Schulz) 9 | // All Rights Reserved 10 | // {fmt} support for ranges, containers and types tuple interface. 11 | 12 | #include "fmt/ranges.h" 13 | 14 | /// Check if 'if constexpr' is supported. 15 | #if (__cplusplus > 201402L) || \ 16 | (defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910) 17 | 18 | #include "gtest.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | TEST(RangesTest, FormatVector) { 26 | std::vector iv{1, 2, 3, 5, 7, 11}; 27 | auto ivf = fmt::format("{}", iv); 28 | EXPECT_EQ("{1, 2, 3, 5, 7, 11}", ivf); 29 | } 30 | 31 | TEST(RangesTest, FormatVector2) { 32 | std::vector> ivv{{1, 2}, {3, 5}, {7, 11}}; 33 | auto ivf = fmt::format("{}", ivv); 34 | EXPECT_EQ("{{1, 2}, {3, 5}, {7, 11}}", ivf); 35 | } 36 | 37 | TEST(RangesTest, FormatMap) { 38 | std::map simap{{"one", 1}, {"two", 2}}; 39 | EXPECT_EQ("{(\"one\", 1), (\"two\", 2)}", fmt::format("{}", simap)); 40 | } 41 | 42 | TEST(RangesTest, FormatPair) { 43 | std::pair pa1{42, 3.14159265358979f}; 44 | EXPECT_EQ("(42, 3.14159)", fmt::format("{}", pa1)); 45 | } 46 | 47 | TEST(RangesTest, FormatTuple) { 48 | std::tuple tu1{42, 3.14159265358979f, 49 | "this is tuple", 'i'}; 50 | EXPECT_EQ("(42, 3.14159, \"this is tuple\", 'i')", fmt::format("{}", tu1)); 51 | } 52 | 53 | struct my_struct { 54 | int32_t i; 55 | std::string str; // can throw 56 | template 57 | decltype(auto) get() const noexcept { 58 | if constexpr (N == 0) 59 | return i; 60 | else if constexpr (N == 1) 61 | return fmt::string_view{str}; 62 | } 63 | }; 64 | 65 | template 66 | decltype(auto) get(const my_struct& s) noexcept { 67 | return s.get(); 68 | } 69 | 70 | namespace std { 71 | 72 | template <> 73 | struct tuple_size : std::integral_constant {}; 74 | 75 | template 76 | struct tuple_element { 77 | using type = decltype(std::declval().get()); 78 | }; 79 | 80 | } // namespace std 81 | 82 | TEST(RangesTest, FormatStruct) { 83 | my_struct mst{13, "my struct"}; 84 | EXPECT_EQ("(13, \"my struct\")", fmt::format("{}", mst)); 85 | } 86 | 87 | #endif // (__cplusplus > 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG > 88 | // 201402L && _MSC_VER >= 1910) 89 | -------------------------------------------------------------------------------- /doc/bootstrap/mixins/forms.less: -------------------------------------------------------------------------------- 1 | // Form validation states 2 | // 3 | // Used in forms.less to generate the form validation CSS for warnings, errors, 4 | // and successes. 5 | 6 | .form-control-validation(@text-color: #555; @border-color: #ccc; @background-color: #f5f5f5) { 7 | // Color the label and help text 8 | .help-block, 9 | .control-label, 10 | .radio, 11 | .checkbox, 12 | .radio-inline, 13 | .checkbox-inline, 14 | &.radio label, 15 | &.checkbox label, 16 | &.radio-inline label, 17 | &.checkbox-inline label { 18 | color: @text-color; 19 | } 20 | // Set the border and box shadow on specific inputs to match 21 | .form-control { 22 | border-color: @border-color; 23 | .box-shadow(inset 0 1px 1px rgba(0,0,0,.075)); // Redeclare so transitions work 24 | &:focus { 25 | border-color: darken(@border-color, 10%); 26 | @shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten(@border-color, 20%); 27 | .box-shadow(@shadow); 28 | } 29 | } 30 | // Set validation states also for addons 31 | .input-group-addon { 32 | color: @text-color; 33 | border-color: @border-color; 34 | background-color: @background-color; 35 | } 36 | // Optional feedback icon 37 | .form-control-feedback { 38 | color: @text-color; 39 | } 40 | } 41 | 42 | 43 | // Form control focus state 44 | // 45 | // Generate a customized focus state and for any input with the specified color, 46 | // which defaults to the `@input-border-focus` variable. 47 | // 48 | // We highly encourage you to not customize the default value, but instead use 49 | // this to tweak colors on an as-needed basis. This aesthetic change is based on 50 | // WebKit's default styles, but applicable to a wider range of browsers. Its 51 | // usability and accessibility should be taken into account with any change. 52 | // 53 | // Example usage: change the default blue border and shadow to white for better 54 | // contrast against a dark gray background. 55 | .form-control-focus(@color: @input-border-focus) { 56 | @color-rgba: rgba(red(@color), green(@color), blue(@color), .6); 57 | &:focus { 58 | border-color: @color; 59 | outline: 0; 60 | .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px @{color-rgba}"); 61 | } 62 | } 63 | 64 | // Form control sizing 65 | // 66 | // Relative text size, padding, and border-radii changes for form controls. For 67 | // horizontal sizing, wrap controls in the predefined grid classes. ` 26 | 27 | 28 | 29 | {% if button %} 30 | 31 | {% endif %} 32 | 33 | {%- endmacro %} 34 | 35 | {% block header %} 36 | 82 | {% if pagename == "index" %} 83 | {% set download_url = 'https://github.com/fmtlib/fmt/releases/download' %} 84 |
85 |
86 |

{fmt}

87 |

Small, safe and fast formatting library

88 |
89 | {% set name = 'fmt' if version.split('.')[0]|int >= 3 else 'cppformat' %} 90 | 92 | Download 93 | 94 | 96 | 103 |
104 |
105 |
106 | {% endif %} 107 | {% endblock %} 108 | 109 | {# Disable relbars. #} 110 | {% block relbar1 %} 111 | {% endblock %} 112 | {% block relbar2 %} 113 | {% endblock %} 114 | 115 | {% block content %} 116 |
117 |
118 | {# Sidebar is currently disabled. 119 |
120 | 135 |
136 | #} 137 | 138 |
139 | {% block body %} {% endblock %} 140 |
141 |
142 |
143 | {% endblock %} 144 | 145 | {% block footer %} 146 | {{ super() }} 147 | {# Placed at the end of the document so the pages load faster. #} 148 | 149 | {% endblock %} 150 | -------------------------------------------------------------------------------- /doc/bootstrap/navs.less: -------------------------------------------------------------------------------- 1 | // 2 | // Navs 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | // -------------------------------------------------- 8 | 9 | .nav { 10 | margin-bottom: 0; 11 | padding-left: 0; // Override default ul/ol 12 | list-style: none; 13 | &:extend(.clearfix all); 14 | 15 | > li { 16 | position: relative; 17 | display: block; 18 | 19 | > a { 20 | position: relative; 21 | display: block; 22 | padding: @nav-link-padding; 23 | &:hover, 24 | &:focus { 25 | text-decoration: none; 26 | background-color: @nav-link-hover-bg; 27 | } 28 | } 29 | 30 | // Disabled state sets text to gray and nukes hover/tab effects 31 | &.disabled > a { 32 | color: @nav-disabled-link-color; 33 | 34 | &:hover, 35 | &:focus { 36 | color: @nav-disabled-link-hover-color; 37 | text-decoration: none; 38 | background-color: transparent; 39 | cursor: @cursor-disabled; 40 | } 41 | } 42 | } 43 | 44 | // Open dropdowns 45 | .open > a { 46 | &, 47 | &:hover, 48 | &:focus { 49 | background-color: @nav-link-hover-bg; 50 | border-color: @link-color; 51 | } 52 | } 53 | 54 | // Nav dividers (deprecated with v3.0.1) 55 | // 56 | // This should have been removed in v3 with the dropping of `.nav-list`, but 57 | // we missed it. We don't currently support this anywhere, but in the interest 58 | // of maintaining backward compatibility in case you use it, it's deprecated. 59 | .nav-divider { 60 | .nav-divider(); 61 | } 62 | 63 | // Prevent IE8 from misplacing imgs 64 | // 65 | // See https://github.com/h5bp/html5-boilerplate/issues/984#issuecomment-3985989 66 | > li > a > img { 67 | max-width: none; 68 | } 69 | } 70 | 71 | 72 | // Tabs 73 | // ------------------------- 74 | 75 | // Give the tabs something to sit on 76 | .nav-tabs { 77 | border-bottom: 1px solid @nav-tabs-border-color; 78 | > li { 79 | float: left; 80 | // Make the list-items overlay the bottom border 81 | margin-bottom: -1px; 82 | 83 | // Actual tabs (as links) 84 | > a { 85 | margin-right: 2px; 86 | line-height: @line-height-base; 87 | border: 1px solid transparent; 88 | border-radius: @border-radius-base @border-radius-base 0 0; 89 | &:hover { 90 | border-color: @nav-tabs-link-hover-border-color @nav-tabs-link-hover-border-color @nav-tabs-border-color; 91 | } 92 | } 93 | 94 | // Active state, and its :hover to override normal :hover 95 | &.active > a { 96 | &, 97 | &:hover, 98 | &:focus { 99 | color: @nav-tabs-active-link-hover-color; 100 | background-color: @nav-tabs-active-link-hover-bg; 101 | border: 1px solid @nav-tabs-active-link-hover-border-color; 102 | border-bottom-color: transparent; 103 | cursor: default; 104 | } 105 | } 106 | } 107 | // pulling this in mainly for less shorthand 108 | &.nav-justified { 109 | .nav-justified(); 110 | .nav-tabs-justified(); 111 | } 112 | } 113 | 114 | 115 | // Pills 116 | // ------------------------- 117 | .nav-pills { 118 | > li { 119 | float: left; 120 | 121 | // Links rendered as pills 122 | > a { 123 | border-radius: @nav-pills-border-radius; 124 | } 125 | + li { 126 | margin-left: 2px; 127 | } 128 | 129 | // Active state 130 | &.active > a { 131 | &, 132 | &:hover, 133 | &:focus { 134 | color: @nav-pills-active-link-hover-color; 135 | background-color: @nav-pills-active-link-hover-bg; 136 | } 137 | } 138 | } 139 | } 140 | 141 | 142 | // Stacked pills 143 | .nav-stacked { 144 | > li { 145 | float: none; 146 | + li { 147 | margin-top: 2px; 148 | margin-left: 0; // no need for this gap between nav items 149 | } 150 | } 151 | } 152 | 153 | 154 | // Nav variations 155 | // -------------------------------------------------- 156 | 157 | // Justified nav links 158 | // ------------------------- 159 | 160 | .nav-justified { 161 | width: 100%; 162 | 163 | > li { 164 | float: none; 165 | > a { 166 | text-align: center; 167 | margin-bottom: 5px; 168 | } 169 | } 170 | 171 | > .dropdown .dropdown-menu { 172 | top: auto; 173 | left: auto; 174 | } 175 | 176 | @media (min-width: @screen-sm-min) { 177 | > li { 178 | display: table-cell; 179 | width: 1%; 180 | > a { 181 | margin-bottom: 0; 182 | } 183 | } 184 | } 185 | } 186 | 187 | // Move borders to anchors instead of bottom of list 188 | // 189 | // Mixin for adding on top the shared `.nav-justified` styles for our tabs 190 | .nav-tabs-justified { 191 | border-bottom: 0; 192 | 193 | > li > a { 194 | // Override margin from .nav-tabs 195 | margin-right: 0; 196 | border-radius: @border-radius-base; 197 | } 198 | 199 | > .active > a, 200 | > .active > a:hover, 201 | > .active > a:focus { 202 | border: 1px solid @nav-tabs-justified-link-border-color; 203 | } 204 | 205 | @media (min-width: @screen-sm-min) { 206 | > li > a { 207 | border-bottom: 1px solid @nav-tabs-justified-link-border-color; 208 | border-radius: @border-radius-base @border-radius-base 0 0; 209 | } 210 | > .active > a, 211 | > .active > a:hover, 212 | > .active > a:focus { 213 | border-bottom-color: @nav-tabs-justified-active-link-border-color; 214 | } 215 | } 216 | } 217 | 218 | 219 | // Tabbable tabs 220 | // ------------------------- 221 | 222 | // Hide tabbable panes to start, show them when `.active` 223 | .tab-content { 224 | > .tab-pane { 225 | display: none; 226 | } 227 | > .active { 228 | display: block; 229 | } 230 | } 231 | 232 | 233 | // Dropdowns 234 | // ------------------------- 235 | 236 | // Specific dropdowns 237 | .nav-tabs .dropdown-menu { 238 | // make dropdown border overlap tab border 239 | margin-top: -1px; 240 | // Remove the top rounded corners here since there is a hard edge above the menu 241 | .border-top-radius(0); 242 | } 243 | -------------------------------------------------------------------------------- /test/gtest-extra.h: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - custom Google Test assertions 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #ifndef FMT_GTEST_EXTRA_H_ 9 | #define FMT_GTEST_EXTRA_H_ 10 | 11 | #include 12 | #include "gmock.h" 13 | 14 | #include "fmt/core.h" 15 | 16 | #ifndef FMT_USE_FILE_DESCRIPTORS 17 | # define FMT_USE_FILE_DESCRIPTORS 0 18 | #endif 19 | 20 | #if FMT_USE_FILE_DESCRIPTORS 21 | # include "fmt/posix.h" 22 | #endif 23 | 24 | #define FMT_TEST_THROW_(statement, expected_exception, expected_message, fail) \ 25 | GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ 26 | if (::testing::AssertionResult gtest_ar = ::testing::AssertionSuccess()) { \ 27 | std::string gtest_expected_message = expected_message; \ 28 | bool gtest_caught_expected = false; \ 29 | try { \ 30 | GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ 31 | } \ 32 | catch (expected_exception const& e) { \ 33 | if (gtest_expected_message != e.what()) { \ 34 | gtest_ar \ 35 | << #statement " throws an exception with a different message.\n" \ 36 | << "Expected: " << gtest_expected_message << "\n" \ 37 | << " Actual: " << e.what(); \ 38 | goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ 39 | } \ 40 | gtest_caught_expected = true; \ 41 | } \ 42 | catch (...) { \ 43 | gtest_ar << \ 44 | "Expected: " #statement " throws an exception of type " \ 45 | #expected_exception ".\n Actual: it throws a different type."; \ 46 | goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ 47 | } \ 48 | if (!gtest_caught_expected) { \ 49 | gtest_ar << \ 50 | "Expected: " #statement " throws an exception of type " \ 51 | #expected_exception ".\n Actual: it throws nothing."; \ 52 | goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ 53 | } \ 54 | } else \ 55 | GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \ 56 | fail(gtest_ar.failure_message()) 57 | 58 | // Tests that the statement throws the expected exception and the exception's 59 | // what() method returns expected message. 60 | #define EXPECT_THROW_MSG(statement, expected_exception, expected_message) \ 61 | FMT_TEST_THROW_(statement, expected_exception, \ 62 | expected_message, GTEST_NONFATAL_FAILURE_) 63 | 64 | std::string format_system_error(int error_code, fmt::string_view message); 65 | 66 | #define EXPECT_SYSTEM_ERROR(statement, error_code, message) \ 67 | EXPECT_THROW_MSG(statement, fmt::system_error, \ 68 | format_system_error(error_code, message)) 69 | 70 | #if FMT_USE_FILE_DESCRIPTORS 71 | 72 | // Captures file output by redirecting it to a pipe. 73 | // The output it can handle is limited by the pipe capacity. 74 | class OutputRedirect { 75 | private: 76 | FILE *file_; 77 | fmt::file original_; // Original file passed to redirector. 78 | fmt::file read_end_; // Read end of the pipe where the output is redirected. 79 | 80 | GTEST_DISALLOW_COPY_AND_ASSIGN_(OutputRedirect); 81 | 82 | void flush(); 83 | void restore(); 84 | 85 | public: 86 | explicit OutputRedirect(FILE *file); 87 | ~OutputRedirect() FMT_NOEXCEPT; 88 | 89 | // Restores the original file, reads output from the pipe into a string 90 | // and returns it. 91 | std::string restore_and_read(); 92 | }; 93 | 94 | #define FMT_TEST_WRITE_(statement, expected_output, file, fail) \ 95 | GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ 96 | if (::testing::AssertionResult gtest_ar = ::testing::AssertionSuccess()) { \ 97 | std::string gtest_expected_output = expected_output; \ 98 | OutputRedirect gtest_redir(file); \ 99 | GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ 100 | std::string gtest_output = gtest_redir.restore_and_read(); \ 101 | if (gtest_output != gtest_expected_output) { \ 102 | gtest_ar \ 103 | << #statement " produces different output.\n" \ 104 | << "Expected: " << gtest_expected_output << "\n" \ 105 | << " Actual: " << gtest_output; \ 106 | goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ 107 | } \ 108 | } else \ 109 | GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \ 110 | fail(gtest_ar.failure_message()) 111 | 112 | // Tests that the statement writes the expected output to file. 113 | #define EXPECT_WRITE(file, statement, expected_output) \ 114 | FMT_TEST_WRITE_(statement, expected_output, file, GTEST_NONFATAL_FAILURE_) 115 | 116 | #ifdef _MSC_VER 117 | 118 | // Suppresses Windows assertions on invalid file descriptors, making 119 | // POSIX functions return proper error codes instead of crashing on Windows. 120 | class SuppressAssert { 121 | private: 122 | _invalid_parameter_handler original_handler_; 123 | int original_report_mode_; 124 | 125 | static void handle_invalid_parameter(const wchar_t *, 126 | const wchar_t *, const wchar_t *, unsigned , uintptr_t) {} 127 | 128 | public: 129 | SuppressAssert() 130 | : original_handler_(_set_invalid_parameter_handler(handle_invalid_parameter)), 131 | original_report_mode_(_CrtSetReportMode(_CRT_ASSERT, 0)) { 132 | } 133 | ~SuppressAssert() { 134 | _set_invalid_parameter_handler(original_handler_); 135 | _CrtSetReportMode(_CRT_ASSERT, original_report_mode_); 136 | } 137 | }; 138 | 139 | # define SUPPRESS_ASSERT(statement) { SuppressAssert sa; statement; } 140 | #else 141 | # define SUPPRESS_ASSERT(statement) statement 142 | #endif // _MSC_VER 143 | 144 | #define EXPECT_SYSTEM_ERROR_NOASSERT(statement, error_code, message) \ 145 | EXPECT_SYSTEM_ERROR(SUPPRESS_ASSERT(statement), error_code, message) 146 | 147 | // Attempts to read count characters from a file. 148 | std::string read(fmt::file &f, std::size_t count); 149 | 150 | #define EXPECT_READ(file, expected_content) \ 151 | EXPECT_EQ(expected_content, read(file, std::strlen(expected_content))) 152 | 153 | #endif // FMT_USE_FILE_DESCRIPTORS 154 | 155 | template 156 | struct ScopedMock : testing::StrictMock { 157 | ScopedMock() { Mock::instance = this; } 158 | ~ScopedMock() { Mock::instance = nullptr; } 159 | }; 160 | 161 | #endif // FMT_GTEST_EXTRA_H_ 162 | -------------------------------------------------------------------------------- /doc/bootstrap/carousel.less: -------------------------------------------------------------------------------- 1 | // 2 | // Carousel 3 | // -------------------------------------------------- 4 | 5 | 6 | // Wrapper for the slide container and indicators 7 | .carousel { 8 | position: relative; 9 | } 10 | 11 | .carousel-inner { 12 | position: relative; 13 | overflow: hidden; 14 | width: 100%; 15 | 16 | > .item { 17 | display: none; 18 | position: relative; 19 | .transition(.6s ease-in-out left); 20 | 21 | // Account for jankitude on images 22 | > img, 23 | > a > img { 24 | &:extend(.img-responsive); 25 | line-height: 1; 26 | } 27 | 28 | // WebKit CSS3 transforms for supported devices 29 | @media all and (transform-3d), (-webkit-transform-3d) { 30 | .transition-transform(~'0.6s ease-in-out'); 31 | .backface-visibility(~'hidden'); 32 | .perspective(1000); 33 | 34 | &.next, 35 | &.active.right { 36 | .translate3d(100%, 0, 0); 37 | left: 0; 38 | } 39 | &.prev, 40 | &.active.left { 41 | .translate3d(-100%, 0, 0); 42 | left: 0; 43 | } 44 | &.next.left, 45 | &.prev.right, 46 | &.active { 47 | .translate3d(0, 0, 0); 48 | left: 0; 49 | } 50 | } 51 | } 52 | 53 | > .active, 54 | > .next, 55 | > .prev { 56 | display: block; 57 | } 58 | 59 | > .active { 60 | left: 0; 61 | } 62 | 63 | > .next, 64 | > .prev { 65 | position: absolute; 66 | top: 0; 67 | width: 100%; 68 | } 69 | 70 | > .next { 71 | left: 100%; 72 | } 73 | > .prev { 74 | left: -100%; 75 | } 76 | > .next.left, 77 | > .prev.right { 78 | left: 0; 79 | } 80 | 81 | > .active.left { 82 | left: -100%; 83 | } 84 | > .active.right { 85 | left: 100%; 86 | } 87 | 88 | } 89 | 90 | // Left/right controls for nav 91 | // --------------------------- 92 | 93 | .carousel-control { 94 | position: absolute; 95 | top: 0; 96 | left: 0; 97 | bottom: 0; 98 | width: @carousel-control-width; 99 | .opacity(@carousel-control-opacity); 100 | font-size: @carousel-control-font-size; 101 | color: @carousel-control-color; 102 | text-align: center; 103 | text-shadow: @carousel-text-shadow; 104 | // We can't have this transition here because WebKit cancels the carousel 105 | // animation if you trip this while in the middle of another animation. 106 | 107 | // Set gradients for backgrounds 108 | &.left { 109 | #gradient > .horizontal(@start-color: rgba(0,0,0,.5); @end-color: rgba(0,0,0,.0001)); 110 | } 111 | &.right { 112 | left: auto; 113 | right: 0; 114 | #gradient > .horizontal(@start-color: rgba(0,0,0,.0001); @end-color: rgba(0,0,0,.5)); 115 | } 116 | 117 | // Hover/focus state 118 | &:hover, 119 | &:focus { 120 | outline: 0; 121 | color: @carousel-control-color; 122 | text-decoration: none; 123 | .opacity(.9); 124 | } 125 | 126 | // Toggles 127 | .icon-prev, 128 | .icon-next, 129 | .glyphicon-chevron-left, 130 | .glyphicon-chevron-right { 131 | position: absolute; 132 | top: 50%; 133 | z-index: 5; 134 | display: inline-block; 135 | } 136 | .icon-prev, 137 | .glyphicon-chevron-left { 138 | left: 50%; 139 | margin-left: -10px; 140 | } 141 | .icon-next, 142 | .glyphicon-chevron-right { 143 | right: 50%; 144 | margin-right: -10px; 145 | } 146 | .icon-prev, 147 | .icon-next { 148 | width: 20px; 149 | height: 20px; 150 | margin-top: -10px; 151 | line-height: 1; 152 | font-family: serif; 153 | } 154 | 155 | 156 | .icon-prev { 157 | &:before { 158 | content: '\2039';// SINGLE LEFT-POINTING ANGLE QUOTATION MARK (U+2039) 159 | } 160 | } 161 | .icon-next { 162 | &:before { 163 | content: '\203a';// SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (U+203A) 164 | } 165 | } 166 | } 167 | 168 | // Optional indicator pips 169 | // 170 | // Add an unordered list with the following class and add a list item for each 171 | // slide your carousel holds. 172 | 173 | .carousel-indicators { 174 | position: absolute; 175 | bottom: 10px; 176 | left: 50%; 177 | z-index: 15; 178 | width: 60%; 179 | margin-left: -30%; 180 | padding-left: 0; 181 | list-style: none; 182 | text-align: center; 183 | 184 | li { 185 | display: inline-block; 186 | width: 10px; 187 | height: 10px; 188 | margin: 1px; 189 | text-indent: -999px; 190 | border: 1px solid @carousel-indicator-border-color; 191 | border-radius: 10px; 192 | cursor: pointer; 193 | 194 | // IE8-9 hack for event handling 195 | // 196 | // Internet Explorer 8-9 does not support clicks on elements without a set 197 | // `background-color`. We cannot use `filter` since that's not viewed as a 198 | // background color by the browser. Thus, a hack is needed. 199 | // See https://developer.mozilla.org/en-US/docs/Web/Events/click#Internet_Explorer 200 | // 201 | // For IE8, we set solid black as it doesn't support `rgba()`. For IE9, we 202 | // set alpha transparency for the best results possible. 203 | background-color: #000 \9; // IE8 204 | background-color: rgba(0,0,0,0); // IE9 205 | } 206 | .active { 207 | margin: 0; 208 | width: 12px; 209 | height: 12px; 210 | background-color: @carousel-indicator-active-bg; 211 | } 212 | } 213 | 214 | // Optional captions 215 | // ----------------------------- 216 | // Hidden by default for smaller viewports 217 | .carousel-caption { 218 | position: absolute; 219 | left: 15%; 220 | right: 15%; 221 | bottom: 20px; 222 | z-index: 10; 223 | padding-top: 20px; 224 | padding-bottom: 20px; 225 | color: @carousel-caption-color; 226 | text-align: center; 227 | text-shadow: @carousel-text-shadow; 228 | & .btn { 229 | text-shadow: none; // No shadow for button elements in carousel-caption 230 | } 231 | } 232 | 233 | 234 | // Scale up controls for tablets and up 235 | @media screen and (min-width: @screen-sm-min) { 236 | 237 | // Scale up the controls a smidge 238 | .carousel-control { 239 | .glyphicon-chevron-left, 240 | .glyphicon-chevron-right, 241 | .icon-prev, 242 | .icon-next { 243 | width: 30px; 244 | height: 30px; 245 | margin-top: -15px; 246 | font-size: 30px; 247 | } 248 | .glyphicon-chevron-left, 249 | .icon-prev { 250 | margin-left: -15px; 251 | } 252 | .glyphicon-chevron-right, 253 | .icon-next { 254 | margin-right: -15px; 255 | } 256 | } 257 | 258 | // Show and left align the captions 259 | .carousel-caption { 260 | left: 20%; 261 | right: 20%; 262 | padding-bottom: 30px; 263 | } 264 | 265 | // Move up the indicators 266 | .carousel-indicators { 267 | bottom: 20px; 268 | } 269 | } 270 | -------------------------------------------------------------------------------- /doc/bootstrap/button-groups.less: -------------------------------------------------------------------------------- 1 | // 2 | // Button groups 3 | // -------------------------------------------------- 4 | 5 | // Make the div behave like a button 6 | .btn-group, 7 | .btn-group-vertical { 8 | position: relative; 9 | display: inline-block; 10 | vertical-align: middle; // match .btn alignment given font-size hack above 11 | > .btn { 12 | position: relative; 13 | float: left; 14 | // Bring the "active" button to the front 15 | &:hover, 16 | &:focus, 17 | &:active, 18 | &.active { 19 | z-index: 2; 20 | } 21 | } 22 | } 23 | 24 | // Prevent double borders when buttons are next to each other 25 | .btn-group { 26 | .btn + .btn, 27 | .btn + .btn-group, 28 | .btn-group + .btn, 29 | .btn-group + .btn-group { 30 | margin-left: -1px; 31 | } 32 | } 33 | 34 | // Optional: Group multiple button groups together for a toolbar 35 | .btn-toolbar { 36 | margin-left: -5px; // Offset the first child's margin 37 | &:extend(.clearfix all); 38 | 39 | .btn-group, 40 | .input-group { 41 | float: left; 42 | } 43 | > .btn, 44 | > .btn-group, 45 | > .input-group { 46 | margin-left: 5px; 47 | } 48 | } 49 | 50 | .btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) { 51 | border-radius: 0; 52 | } 53 | 54 | // Set corners individual because sometimes a single button can be in a .btn-group and we need :first-child and :last-child to both match 55 | .btn-group > .btn:first-child { 56 | margin-left: 0; 57 | &:not(:last-child):not(.dropdown-toggle) { 58 | .border-right-radius(0); 59 | } 60 | } 61 | // Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it 62 | .btn-group > .btn:last-child:not(:first-child), 63 | .btn-group > .dropdown-toggle:not(:first-child) { 64 | .border-left-radius(0); 65 | } 66 | 67 | // Custom edits for including btn-groups within btn-groups (useful for including dropdown buttons within a btn-group) 68 | .btn-group > .btn-group { 69 | float: left; 70 | } 71 | .btn-group > .btn-group:not(:first-child):not(:last-child) > .btn { 72 | border-radius: 0; 73 | } 74 | .btn-group > .btn-group:first-child:not(:last-child) { 75 | > .btn:last-child, 76 | > .dropdown-toggle { 77 | .border-right-radius(0); 78 | } 79 | } 80 | .btn-group > .btn-group:last-child:not(:first-child) > .btn:first-child { 81 | .border-left-radius(0); 82 | } 83 | 84 | // On active and open, don't show outline 85 | .btn-group .dropdown-toggle:active, 86 | .btn-group.open .dropdown-toggle { 87 | outline: 0; 88 | } 89 | 90 | 91 | // Sizing 92 | // 93 | // Remix the default button sizing classes into new ones for easier manipulation. 94 | 95 | .btn-group-xs > .btn { &:extend(.btn-xs); } 96 | .btn-group-sm > .btn { &:extend(.btn-sm); } 97 | .btn-group-lg > .btn { &:extend(.btn-lg); } 98 | 99 | 100 | // Split button dropdowns 101 | // ---------------------- 102 | 103 | // Give the line between buttons some depth 104 | .btn-group > .btn + .dropdown-toggle { 105 | padding-left: 8px; 106 | padding-right: 8px; 107 | } 108 | .btn-group > .btn-lg + .dropdown-toggle { 109 | padding-left: 12px; 110 | padding-right: 12px; 111 | } 112 | 113 | // The clickable button for toggling the menu 114 | // Remove the gradient and set the same inset shadow as the :active state 115 | .btn-group.open .dropdown-toggle { 116 | .box-shadow(inset 0 3px 5px rgba(0,0,0,.125)); 117 | 118 | // Show no shadow for `.btn-link` since it has no other button styles. 119 | &.btn-link { 120 | .box-shadow(none); 121 | } 122 | } 123 | 124 | 125 | // Reposition the caret 126 | .btn .caret { 127 | margin-left: 0; 128 | } 129 | // Carets in other button sizes 130 | .btn-lg .caret { 131 | border-width: @caret-width-large @caret-width-large 0; 132 | border-bottom-width: 0; 133 | } 134 | // Upside down carets for .dropup 135 | .dropup .btn-lg .caret { 136 | border-width: 0 @caret-width-large @caret-width-large; 137 | } 138 | 139 | 140 | // Vertical button groups 141 | // ---------------------- 142 | 143 | .btn-group-vertical { 144 | > .btn, 145 | > .btn-group, 146 | > .btn-group > .btn { 147 | display: block; 148 | float: none; 149 | width: 100%; 150 | max-width: 100%; 151 | } 152 | 153 | // Clear floats so dropdown menus can be properly placed 154 | > .btn-group { 155 | &:extend(.clearfix all); 156 | > .btn { 157 | float: none; 158 | } 159 | } 160 | 161 | > .btn + .btn, 162 | > .btn + .btn-group, 163 | > .btn-group + .btn, 164 | > .btn-group + .btn-group { 165 | margin-top: -1px; 166 | margin-left: 0; 167 | } 168 | } 169 | 170 | .btn-group-vertical > .btn { 171 | &:not(:first-child):not(:last-child) { 172 | border-radius: 0; 173 | } 174 | &:first-child:not(:last-child) { 175 | border-top-right-radius: @border-radius-base; 176 | .border-bottom-radius(0); 177 | } 178 | &:last-child:not(:first-child) { 179 | border-bottom-left-radius: @border-radius-base; 180 | .border-top-radius(0); 181 | } 182 | } 183 | .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn { 184 | border-radius: 0; 185 | } 186 | .btn-group-vertical > .btn-group:first-child:not(:last-child) { 187 | > .btn:last-child, 188 | > .dropdown-toggle { 189 | .border-bottom-radius(0); 190 | } 191 | } 192 | .btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child { 193 | .border-top-radius(0); 194 | } 195 | 196 | 197 | // Justified button groups 198 | // ---------------------- 199 | 200 | .btn-group-justified { 201 | display: table; 202 | width: 100%; 203 | table-layout: fixed; 204 | border-collapse: separate; 205 | > .btn, 206 | > .btn-group { 207 | float: none; 208 | display: table-cell; 209 | width: 1%; 210 | } 211 | > .btn-group .btn { 212 | width: 100%; 213 | } 214 | 215 | > .btn-group .dropdown-menu { 216 | left: auto; 217 | } 218 | } 219 | 220 | 221 | // Checkbox and radio options 222 | // 223 | // In order to support the browser's form validation feedback, powered by the 224 | // `required` attribute, we have to "hide" the inputs via `clip`. We cannot use 225 | // `display: none;` or `visibility: hidden;` as that also hides the popover. 226 | // Simply visually hiding the inputs via `opacity` would leave them clickable in 227 | // certain cases which is prevented by using `clip` and `pointer-events`. 228 | // This way, we ensure a DOM element is visible to position the popover from. 229 | // 230 | // See https://github.com/twbs/bootstrap/pull/12794 and 231 | // https://github.com/twbs/bootstrap/pull/14559 for more information. 232 | 233 | [data-toggle="buttons"] { 234 | > .btn, 235 | > .btn-group > .btn { 236 | input[type="radio"], 237 | input[type="checkbox"] { 238 | position: absolute; 239 | clip: rect(0,0,0,0); 240 | pointer-events: none; 241 | } 242 | } 243 | } 244 | --------------------------------------------------------------------------------