diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..6e211a37a --- /dev/null +++ b/.clang-format @@ -0,0 +1,8 @@ +BasedOnStyle: Google +IndentWidth: 2 +--- +Language: Cpp + +PointerAlignment: Left +AlwaysBreakAfterReturnType: None +SortIncludes: true \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..6c187d317 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,28 @@ +module.exports = { + extends: [ + "plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. + ], + parserOptions: { + ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features + sourceType: "module" // Allows for the use of imports + }, + overrides: [ + { + files: ["*.ts", "*.tsx"], + parser: "@typescript-eslint/parser", // Specifies the ESLint parser + extends: [ + "plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin + "prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier + "plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. + ], + parserOptions: { + ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features + sourceType: "module" // Allows for the use of imports + }, + rules: { + "@typescript-eslint/camelcase": 0, + "@typescript-eslint/no-var-requires": 0 + } + } + ] +}; diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 000000000..c8c6a5496 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + semi: true, + trailingComma: 'all', + singleQuote: true, + printWidth: 120, + tabWidth: 4, +}; diff --git a/package-lock.json b/package-lock.json index 62aefc01c..54057ddce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,19 +14,19 @@ } }, "@babel/core": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.6.2.tgz", - "integrity": "sha512-l8zto/fuoZIbncm+01p8zPSDZu/VuuJhAfA7d/AbzM09WR7iVhavvfNDYCNpo1VvLk6E6xgAoP9P+/EMJHuRkQ==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.7.2.tgz", + "integrity": "sha512-eeD7VEZKfhK1KUXGiyPFettgF3m513f8FoBSWiQ1xTvl1RAopLs42Wp9+Ze911I6H0N9lNqJMDgoZT7gHsipeQ==", "dev": true, "requires": { "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.6.2", - "@babel/helpers": "^7.6.2", - "@babel/parser": "^7.6.2", - "@babel/template": "^7.6.0", - "@babel/traverse": "^7.6.2", - "@babel/types": "^7.6.0", - "convert-source-map": "^1.1.0", + "@babel/generator": "^7.7.2", + "@babel/helpers": "^7.7.0", + "@babel/parser": "^7.7.2", + "@babel/template": "^7.7.0", + "@babel/traverse": "^7.7.2", + "@babel/types": "^7.7.2", + "convert-source-map": "^1.7.0", "debug": "^4.1.0", "json5": "^2.1.0", "lodash": "^4.17.13", @@ -65,12 +65,12 @@ } }, "@babel/generator": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.6.2.tgz", - "integrity": "sha512-j8iHaIW4gGPnViaIHI7e9t/Hl8qLjERI6DcV9kEpAIDJsAOrcnXqRS7t+QbhL76pwbtqP+QCQLL0z1CyVmtjjQ==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.2.tgz", + "integrity": "sha512-WthSArvAjYLz4TcbKOi88me+KmDJdKSlfwwN8CnUYn9jBkzhq0ZEPuBfkAWIvjJ3AdEV1Cf/+eSQTnp3IDJKlQ==", "dev": true, "requires": { - "@babel/types": "^7.6.0", + "@babel/types": "^7.7.2", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" @@ -85,23 +85,23 @@ } }, "@babel/helper-function-name": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz", - "integrity": "sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.0.tgz", + "integrity": "sha512-tDsJgMUAP00Ugv8O2aGEua5I2apkaQO7lBGUq1ocwN3G23JE5Dcq0uh3GvFTChPa4b40AWiAsLvCZOA2rdnQ7Q==", "dev": true, "requires": { - "@babel/helper-get-function-arity": "^7.0.0", - "@babel/template": "^7.1.0", - "@babel/types": "^7.0.0" + "@babel/helper-get-function-arity": "^7.7.0", + "@babel/template": "^7.7.0", + "@babel/types": "^7.7.0" } }, "@babel/helper-get-function-arity": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz", - "integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.0.tgz", + "integrity": "sha512-tLdojOTz4vWcEnHWHCuPN5P85JLZWbm5Fx5ZsMEMPhF3Uoe3O7awrbM2nQ04bDOUToH/2tH/ezKEOR8zEYzqyw==", "dev": true, "requires": { - "@babel/types": "^7.0.0" + "@babel/types": "^7.7.0" } }, "@babel/helper-plugin-utils": { @@ -111,23 +111,23 @@ "dev": true }, "@babel/helper-split-export-declaration": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", - "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.0.tgz", + "integrity": "sha512-HgYSI8rH08neWlAH3CcdkFg9qX9YsZysZI5GD8LjhQib/mM0jGOZOVkoUiiV2Hu978fRtjtsGsW6w0pKHUWtqA==", "dev": true, "requires": { - "@babel/types": "^7.4.4" + "@babel/types": "^7.7.0" } }, "@babel/helpers": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.6.2.tgz", - "integrity": "sha512-3/bAUL8zZxYs1cdX2ilEE0WobqbCmKWr/889lf2SS0PpDcpEIY8pb1CCyz0pEcX3pEb+MCbks1jIokz2xLtGTA==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.7.0.tgz", + "integrity": "sha512-VnNwL4YOhbejHb7x/b5F39Zdg5vIQpUUNzJwx0ww1EcVRt41bbGRZWhAURrfY32T5zTT3qwNOQFWpn+P0i0a2g==", "dev": true, "requires": { - "@babel/template": "^7.6.0", - "@babel/traverse": "^7.6.2", - "@babel/types": "^7.6.0" + "@babel/template": "^7.7.0", + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0" } }, "@babel/highlight": { @@ -142,9 +142,9 @@ } }, "@babel/parser": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.2.tgz", - "integrity": "sha512-mdFqWrSPCmikBoaBYMuBulzTIKuXVPtEISFbRRVNwMWpCms/hmE2kRq0bblUHaNRKrjRlmVbx1sDHmjmRgD2Xg==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.2.tgz", + "integrity": "sha512-DDaR5e0g4ZTb9aP7cpSZLkACEBdoLGwJDWgHtBhrGX7Q1RjhdoMOfexICj5cqTAtpowjGQWfcvfnQG7G2kAB5w==", "dev": true }, "@babel/plugin-syntax-object-rest-spread": { @@ -157,28 +157,28 @@ } }, "@babel/template": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.6.0.tgz", - "integrity": "sha512-5AEH2EXD8euCk446b7edmgFdub/qfH1SN6Nii3+fyXP807QRx9Q73A2N5hNwRRslC2H9sNzaFhsPubkS4L8oNQ==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.7.0.tgz", + "integrity": "sha512-OKcwSYOW1mhWbnTBgQY5lvg1Fxg+VyfQGjcBduZFljfc044J5iDlnDSfhQ867O17XHiSCxYHUxHg2b7ryitbUQ==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.6.0", - "@babel/types": "^7.6.0" + "@babel/parser": "^7.7.0", + "@babel/types": "^7.7.0" } }, "@babel/traverse": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.6.2.tgz", - "integrity": "sha512-8fRE76xNwNttVEF2TwxJDGBLWthUkHWSldmfuBzVRmEDWOtu4XdINTgN7TDWzuLg4bbeIMLvfMFD9we5YcWkRQ==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.7.2.tgz", + "integrity": "sha512-TM01cXib2+rgIZrGJOLaHV/iZUAxf4A0dt5auY6KNZ+cm6aschuJGqKJM3ROTt3raPUdIDk9siAufIFEleRwtw==", "dev": true, "requires": { "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.6.2", - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/parser": "^7.6.2", - "@babel/types": "^7.6.0", + "@babel/generator": "^7.7.2", + "@babel/helper-function-name": "^7.7.0", + "@babel/helper-split-export-declaration": "^7.7.0", + "@babel/parser": "^7.7.2", + "@babel/types": "^7.7.2", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" @@ -202,9 +202,9 @@ } }, "@babel/types": { - "version": "7.6.1", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.6.1.tgz", - "integrity": "sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.2.tgz", + "integrity": "sha512-YTf6PXoh3+eZgRCBzzP25Bugd2ngmpQVrk7kXX0i5N9BO7TFBtIgZYs7WtxtOGs8e6A4ZI7ECkbBCEHeXocvOA==", "dev": true, "requires": { "esutils": "^2.0.2", @@ -239,6 +239,14 @@ "@jest/source-map": "^24.9.0", "chalk": "^2.0.1", "slash": "^2.0.0" + }, + "dependencies": { + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + } } }, "@jest/core": { @@ -277,12 +285,24 @@ "strip-ansi": "^5.0.0" }, "dependencies": { + "ansi-escapes": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "dev": true + }, "ansi-regex": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + }, "strip-ansi": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", @@ -344,6 +364,14 @@ "slash": "^2.0.0", "source-map": "^0.6.0", "string-length": "^2.0.0" + }, + "dependencies": { + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + } } }, "@jest/source-map": { @@ -402,6 +430,14 @@ "slash": "^2.0.0", "source-map": "^0.6.1", "write-file-atomic": "2.4.1" + }, + "dependencies": { + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + } } }, "@jest/types": { @@ -487,6 +523,12 @@ "integrity": "sha512-mTWOE6wC64MoEpv33otJNpQob81l5Pi+NsUkdiiP8EkESraQM94zuus/2s/Vz2Idy1qQkctNINYDZ61nfG1ngQ==", "dev": true }, + "@types/eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", + "dev": true + }, "@types/istanbul-lib-coverage": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", @@ -527,12 +569,24 @@ "integrity": "sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA==", "dev": true }, + "@types/json-schema": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.3.tgz", + "integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==", + "dev": true + }, "@types/node": { "version": "12.12.3", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.3.tgz", "integrity": "sha512-opgSsy+cEF9N8MgaVPnWVtdJ3o4mV2aMHvDq7thkQUFt0EuOHJon4rQpJfhjmNHB+ikl0Cd6WhWIErOyQ+f7tw==", "dev": true }, + "@types/normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", + "dev": true + }, "@types/stack-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", @@ -554,6 +608,79 @@ "integrity": "sha512-gCubfBUZ6KxzoibJ+SCUc/57Ms1jz5NjHe4+dI2krNmU5zCPAphyLJYyTOg06ueIyfj+SaCUqmzun7ImlxDcKg==", "dev": true }, + "@typescript-eslint/eslint-plugin": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.6.1.tgz", + "integrity": "sha512-Z0rddsGqioKbvqfohg7BwkFC3PuNLsB+GE9QkFza7tiDzuHoy0y823Y+oGNDzxNZrYyLjqkZtCTl4vCqOmEN4g==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "2.6.1", + "eslint-utils": "^1.4.2", + "functional-red-black-tree": "^1.0.1", + "regexpp": "^2.0.1", + "tsutils": "^3.17.1" + } + }, + "@typescript-eslint/experimental-utils": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.6.1.tgz", + "integrity": "sha512-EVrrUhl5yBt7fC7c62lWmriq4MIc49zpN3JmrKqfiFXPXCM5ErfEcZYfKOhZXkW6MBjFcJ5kGZqu1b+lyyExUw==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "2.6.1", + "eslint-scope": "^5.0.0" + } + }, + "@typescript-eslint/parser": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.6.1.tgz", + "integrity": "sha512-PDPkUkZ4c7yA+FWqigjwf3ngPUgoLaGjMlFh6TRtbjhqxFBnkElDfckSjm98q9cMr4xRzZ15VrS/xKm6QHYf0w==", + "dev": true, + "requires": { + "@types/eslint-visitor-keys": "^1.0.0", + "@typescript-eslint/experimental-utils": "2.6.1", + "@typescript-eslint/typescript-estree": "2.6.1", + "eslint-visitor-keys": "^1.1.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.6.1.tgz", + "integrity": "sha512-+sTnssW6bcbDZKE8Ce7VV6LdzkQz2Bxk7jzk1J8H1rovoTxnm6iXvYIyncvNsaB/kBCOM63j/LNJfm27bNdUoA==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "glob": "^7.1.4", + "is-glob": "^4.0.1", + "lodash.unescape": "4.0.1", + "semver": "^6.3.0", + "tsutils": "^3.17.1" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "@zeit/schemas": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/@zeit/schemas/-/schemas-2.6.0.tgz", @@ -577,9 +704,9 @@ } }, "acorn": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", - "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", + "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", "dev": true }, "acorn-globals": { @@ -600,6 +727,12 @@ } } }, + "acorn-jsx": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz", + "integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==", + "dev": true + }, "acorn-walk": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.2.0.tgz", @@ -665,10 +798,13 @@ } }, "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.2.1.tgz", + "integrity": "sha512-Cg3ymMAdN10wOk/VYfLV7KCQyv7EDirJ64500sU7n9UlmioEtDuU5Gd+hj73hXSU/ex7tHJSssmyftDdkMLO8Q==", + "dev": true, + "requires": { + "type-fest": "^0.5.2" + } }, "ansi-regex": { "version": "2.1.1", @@ -714,6 +850,15 @@ "integrity": "sha512-XxNTUzKnz1ctK3ZIcI2XUPlD96wbHP2nGqkPKpvk/HNRlPveYrXIVSTk9m3LcqOgDPg3B1nMvdV/K8wZd7PG4w==", "dev": true }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, "arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", @@ -769,6 +914,12 @@ "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, "async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", @@ -809,6 +960,14 @@ "babel-preset-jest": "^24.9.0", "chalk": "^2.4.2", "slash": "^2.0.0" + }, + "dependencies": { + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + } } }, "babel-plugin-istanbul": { @@ -821,6 +980,42 @@ "find-up": "^3.0.0", "istanbul-lib-instrument": "^3.3.0", "test-exclude": "^5.2.3" + }, + "dependencies": { + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + } } }, "babel-plugin-jest-hoist": { @@ -1048,9 +1243,9 @@ } }, "bser": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.0.tgz", - "integrity": "sha512-8zsjWrQkkBoLK6uxASk1nJ2SKv97ltiGDo6A3wA0/yRPz+CwmEyDo0hUrhIuukG2JHpAl3bvFIixw2/3Hi0DOg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", "dev": true, "requires": { "node-int64": "^0.4.0" @@ -1128,6 +1323,32 @@ } } }, + "caller-callsite": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", + "integrity": "sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ=", + "dev": true, + "requires": { + "callsites": "^2.0.0" + }, + "dependencies": { + "callsites": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", + "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", + "dev": true + } + } + }, + "caller-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz", + "integrity": "sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ=", + "dev": true, + "requires": { + "caller-callsite": "^2.0.0" + } + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -1147,14 +1368,6 @@ "dev": true, "requires": { "rsvp": "^4.8.4" - }, - "dependencies": { - "rsvp": { - "version": "4.8.5", - "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", - "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", - "dev": true - } } }, "caseless": { @@ -1190,6 +1403,12 @@ } } }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, "chownr": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", @@ -1201,6 +1420,17 @@ "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", "dev": true }, + "clang-format": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.3.0.tgz", + "integrity": "sha512-Zry9BQsly8stBMDoEa6D91Wi5xkh1Yk9jiULAhoalxppUoeMIoG3yN8mJu2/dyGmc4bqij9GGWFZlYH+qd+EzQ==", + "dev": true, + "requires": { + "async": "^1.5.2", + "glob": "^7.0.0", + "resolve": "^1.1.6" + } + }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -1230,6 +1460,21 @@ "integrity": "sha1-T6kXw+WclKAEzWH47lCdplFocUM=", "dev": true }, + "cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, + "requires": { + "restore-cursor": "^3.1.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, "clipboardy": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-1.2.3.tgz", @@ -1370,6 +1615,13 @@ "delayed-stream": "~1.0.0" } }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "optional": true + }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -1423,9 +1675,9 @@ "dev": true }, "convert-source-map": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", - "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", + "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", "dev": true, "requires": { "safe-buffer": "~5.1.1" @@ -1442,6 +1694,36 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "cosmiconfig": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", + "integrity": "sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA==", + "dev": true, + "requires": { + "import-fresh": "^2.0.0", + "is-directory": "^0.3.1", + "js-yaml": "^3.13.1", + "parse-json": "^4.0.0" + }, + "dependencies": { + "import-fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz", + "integrity": "sha1-2BNVwVYS04bGH53dOSLUMEgipUY=", + "dev": true, + "requires": { + "caller-path": "^2.0.0", + "resolve-from": "^3.0.0" + } + }, + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "dev": true + } + } + }, "cross-env": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-6.0.3.tgz", @@ -1539,9 +1821,9 @@ }, "dependencies": { "whatwg-url": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.0.0.tgz", - "integrity": "sha512-37GeVSIJ3kn1JgKyjiYNmSLP1yzbpb29jdmwBSgkD9h40/hyrR/OifpVUndji3tmwGgD8qpw7iQu3RSbCrBpsQ==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", + "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", "dev": true, "requires": { "lodash.sortby": "^4.7.0", @@ -1666,6 +1948,15 @@ "integrity": "sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew==", "dev": true }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, "domexception": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz", @@ -1698,9 +1989,9 @@ } }, "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "end-of-stream": { @@ -1726,9 +2017,9 @@ } }, "es-abstract": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.15.0.tgz", - "integrity": "sha512-bhkEqWJ2t2lMeaJDuk7okMkJWI/yqgH/EoGwpcvv0XW9RWQsRspI4wt6xuyuvMvvQE3gg/D9HXppgk21w78GyQ==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.16.0.tgz", + "integrity": "sha512-xdQnfykZ9JMEiasTAJZJdMWCQ1Vm00NBw79/AWi7ELfZuuPCSOMDZbT9mkOfSctVtfhb+sAAzrm+j//GjjLHLg==", "dev": true, "requires": { "es-to-primitive": "^1.2.0", @@ -1770,14 +2061,204 @@ "esutils": "^2.0.2", "optionator": "^0.8.1", "source-map": "~0.6.1" + }, + "dependencies": { + "esprima": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", + "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", + "dev": true + } + } + }, + "eslint": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.6.0.tgz", + "integrity": "sha512-PpEBq7b6qY/qrOmpYQ/jTMDYfuQMELR4g4WI1M/NaSDDD/bdcMb+dj4Hgks7p41kW2caXsPsEZAEAyAgjVVC0g==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.0.0", + "globals": "^11.7.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^7.0.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.14", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "strip-json-comments": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "dev": true + } + } + }, + "eslint-config-prettier": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.5.0.tgz", + "integrity": "sha512-cjXp8SbO9VFGW/Z7mbTydqS9to8Z58E5aYhj3e1+Hx7lS9s6gL5ILKNpCqZAFOVYRcSkWPFYljHrEh8QFEK5EQ==", + "dev": true, + "requires": { + "get-stdin": "^6.0.0" + } + }, + "eslint-plugin-prettier": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.1.tgz", + "integrity": "sha512-A+TZuHZ0KU0cnn56/9mfR7/KjUJ9QNVXUhwvRFSR7PGPe0zQR6PTkmyqg1AtUUEOzTqeRsUwyKFh0oVZKVCrtA==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, + "eslint-scope": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", + "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "dev": true + }, + "espree": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz", + "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==", + "dev": true, + "requires": { + "acorn": "^7.1.0", + "acorn-jsx": "^5.1.0", + "eslint-visitor-keys": "^1.1.0" } }, "esprima": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, "estraverse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", @@ -1791,9 +2272,9 @@ "dev": true }, "exec-sh": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/exec-sh/-/exec-sh-0.3.2.tgz", - "integrity": "sha512-9sLAvzhI5nc8TpuQUh4ahMdCrWT00wPWz7j47/emR5+2qEfoZP5zzUXvx+vdx+H6ohhnsYC31iX04QLYJK8zTg==", + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/exec-sh/-/exec-sh-0.3.4.tgz", + "integrity": "sha512-sEFIkc61v75sWeOe72qyrqg2Qg0OuLESziUDk/O/z2qgS15y2gWVFrI6f2Qn/qw/0/NCfCEsmNA4zOjkwEZT1A==", "dev": true }, "execa": { @@ -1900,6 +2381,17 @@ } } }, + "external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, "extglob": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", @@ -1986,6 +2478,12 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", @@ -2031,6 +2529,24 @@ "pend": "~1.2.0" } }, + "figures": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz", + "integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -2055,14 +2571,43 @@ } }, "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, "requires": { - "locate-path": "^3.0.0" + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" } }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + }, + "dependencies": { + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, + "flatted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", + "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", + "dev": true + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -2681,6 +3226,12 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, "gauge": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/gauge/-/gauge-1.2.7.tgz", @@ -2699,6 +3250,12 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true + }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -2734,6 +3291,15 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -2770,9 +3336,9 @@ "dev": true }, "handlebars": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.2.tgz", - "integrity": "sha512-cIv17+GhL8pHHnRJzGu2wwcthL5sb8uDKBHvZ2Dtu5s1YNt0ljbzKbamnc+gr69y7bzwQiBdr5+hOpRd5pnOdg==", + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.1.tgz", + "integrity": "sha512-C29UoFzHe9yM61lOsIlCE5/mQVGrnIOrOq7maQl76L7tYPCgC1og0Ajt6uWnX4ZTxBPnjw+CUvawphwCfJgUnA==", "dev": true, "requires": { "neo-async": "^2.6.0", @@ -2853,9 +3419,9 @@ } }, "hosted-git-info": { - "version": "2.8.4", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.4.tgz", - "integrity": "sha512-pzXIvANXEFrc5oFFXRMkbLPQ2rXRoDERwDLyrcUxGhaZhgP54BBSl9Oheh7Vv0T090cszWBxPjkQQ5Sq1PbBRQ==", + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", + "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", "dev": true }, "html-encoding-sniffer": { @@ -2882,6 +3448,67 @@ "sshpk": "^1.7.0" } }, + "husky": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/husky/-/husky-3.0.9.tgz", + "integrity": "sha512-Yolhupm7le2/MqC1VYLk/cNmYxsSsqKkTyBhzQHhPK1jFnC89mmmNVuGtLNabjDI6Aj8UNIr0KpRNuBkiC4+sg==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "ci-info": "^2.0.0", + "cosmiconfig": "^5.2.1", + "execa": "^1.0.0", + "get-stdin": "^7.0.0", + "opencollective-postinstall": "^2.0.2", + "pkg-dir": "^4.2.0", + "please-upgrade-node": "^3.2.0", + "read-pkg": "^5.2.0", + "run-node": "^1.0.0", + "slash": "^3.0.0" + }, + "dependencies": { + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "get-stdin": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz", + "integrity": "sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ==", + "dev": true + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -2891,6 +3518,22 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz", + "integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, "import-local": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz", @@ -2899,6 +3542,51 @@ "requires": { "pkg-dir": "^3.0.0", "resolve-cwd": "^2.0.0" + }, + "dependencies": { + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, + "requires": { + "find-up": "^3.0.0" + } + } } }, "imurmurhash": { @@ -2926,6 +3614,61 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, + "inquirer": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.0.tgz", + "integrity": "sha512-rSdC7zelHdRQFkWnhsMu2+2SO41mpv2oF2zy4tMhmiLWkcKbOAs87fWAJhVXttKVwhdZvymvnuM95EyEXg2/tQ==", + "dev": true, + "requires": { + "ansi-escapes": "^4.2.1", + "chalk": "^2.4.2", + "cli-cursor": "^3.1.0", + "cli-width": "^2.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.15", + "mute-stream": "0.0.8", + "run-async": "^2.2.0", + "rxjs": "^6.4.0", + "string-width": "^4.1.0", + "strip-ansi": "^5.1.0", + "through": "^2.3.6" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "string-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.1.0.tgz", + "integrity": "sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^5.2.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "invariant": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", @@ -3032,12 +3775,24 @@ } } }, + "is-directory": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz", + "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", + "dev": true + }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", "dev": true }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", @@ -3052,6 +3807,15 @@ "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", "dev": true }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, "is-iojs": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-iojs/-/is-iojs-1.1.0.tgz", @@ -3086,6 +3850,12 @@ "isobject": "^3.0.1" } }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, "is-regex": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", @@ -3254,6 +4024,21 @@ "wrap-ansi": "^5.1.0" } }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", @@ -3281,6 +4066,31 @@ "yargs": "^13.3.0" } }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, "string-width": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", @@ -3557,6 +4367,14 @@ "micromatch": "^3.1.10", "slash": "^2.0.0", "stack-utils": "^1.0.1" + }, + "dependencies": { + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + } } }, "jest-mock": { @@ -3629,18 +4447,6 @@ "jest-worker": "^24.6.0", "source-map-support": "^0.5.6", "throat": "^4.0.0" - }, - "dependencies": { - "source-map-support": { - "version": "0.5.13", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", - "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - } } }, "jest-runtime": { @@ -3691,12 +4497,58 @@ "wrap-ansi": "^5.1.0" } }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + }, "string-width": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", @@ -3807,6 +4659,14 @@ "mkdirp": "^0.5.1", "slash": "^2.0.0", "source-map": "^0.6.0" + }, + "dependencies": { + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + } } }, "jest-validate": { @@ -3844,6 +4704,14 @@ "chalk": "^2.0.1", "jest-util": "^24.9.0", "string-length": "^2.0.0" + }, + "dependencies": { + "ansi-escapes": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "dev": true + } } }, "jest-worker": { @@ -3862,6 +4730,16 @@ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", @@ -3899,6 +4777,14 @@ "whatwg-url": "^6.4.1", "ws": "^5.2.0", "xml-name-validator": "^3.0.0" + }, + "dependencies": { + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", + "dev": true + } } }, "jsesc": { @@ -3928,6 +4814,12 @@ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -4019,6 +4911,12 @@ "type-check": "~0.3.2" } }, + "lines-and-columns": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", + "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", + "dev": true + }, "listenercount": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", @@ -4037,13 +4935,12 @@ } }, "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "dev": true, "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" + "p-locate": "^4.1.0" } }, "lodash": { @@ -4078,6 +4975,12 @@ "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", "dev": true }, + "lodash.unescape": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.unescape/-/lodash.unescape-4.0.1.tgz", + "integrity": "sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=", + "dev": true + }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -4235,6 +5138,12 @@ "mime-db": "1.40.0" } }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, "mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", @@ -4304,6 +5213,12 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "mute-stream": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", + "dev": true + }, "nan": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", @@ -4443,9 +5358,9 @@ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, "nwsapi": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.1.4.tgz", - "integrity": "sha512-iGfd9Y6SFdTNldEy2L0GUhcarIutFmk+MPWIn9dmj8NMIup03G08uUF2KGbbmv/Ux4RT0VZJoP/sVbWA6d/VIw==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.0.tgz", + "integrity": "sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ==", "dev": true }, "oauth-sign": { @@ -4538,6 +5453,21 @@ "wrappy": "1" } }, + "onetime": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "opencollective-postinstall": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.2.tgz", + "integrity": "sha512-pVOEP16TrAO2/fjej1IdOyupJY8KDUM1CvsaScRbw6oddvpQoOfGk4ywha0HKKVAD6RkW4x6Q+tNBwhf3Bgpuw==", + "dev": true + }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", @@ -4549,25 +5479,17 @@ } }, "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", "dev": true, "requires": { "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.4", + "fast-levenshtein": "~2.0.6", "levn": "~0.3.0", "prelude-ls": "~1.1.2", "type-check": "~0.3.2", - "wordwrap": "~1.0.0" - }, - "dependencies": { - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true - } + "word-wrap": "~1.2.3" } }, "os-locale": { @@ -4578,6 +5500,12 @@ "lcid": "^1.0.0" } }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, "p-cancelable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", @@ -4608,12 +5536,12 @@ } }, "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "dev": true, "requires": { - "p-limit": "^2.0.0" + "p-limit": "^2.2.0" } }, "p-reduce": { @@ -4628,6 +5556,15 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", @@ -4651,9 +5588,9 @@ "dev": true }, "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true }, "path-is-absolute": { @@ -4720,12 +5657,21 @@ } }, "pkg-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", - "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, "requires": { - "find-up": "^3.0.0" + "find-up": "^4.0.0" + } + }, + "please-upgrade-node": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", + "integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==", + "dev": true, + "requires": { + "semver-compare": "^1.0.0" } }, "pn": { @@ -4775,6 +5721,15 @@ "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", "dev": true }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "pretty-format": { "version": "24.9.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-24.9.0.tgz", @@ -4870,20 +5825,41 @@ } }, "react-is": { - "version": "16.10.2", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.10.2.tgz", - "integrity": "sha512-INBT1QEgtcCCgvccr5/86CfD71fw9EPmDxgiJX4I2Ddr6ZsV6iFXsuby+qWJPtmNuMY0zByTsG4468P7nHuNWA==", + "version": "16.11.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.11.0.tgz", + "integrity": "sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw==", "dev": true }, "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", "dev": true, "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "dependencies": { + "parse-json": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.0.tgz", + "integrity": "sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1", + "lines-and-columns": "^1.1.6" + } + }, + "type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true + } } }, "read-pkg-up": { @@ -4894,6 +5870,53 @@ "requires": { "find-up": "^3.0.0", "read-pkg": "^3.0.0" + }, + "dependencies": { + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "dev": true, + "requires": { + "load-json-file": "^4.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^3.0.0" + } + } } }, "readable-stream": { @@ -4929,6 +5952,12 @@ "safe-regex": "^1.1.0" } }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, "registry-auth-token": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.2.tgz", @@ -4994,21 +6023,21 @@ } }, "request-promise-core": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.2.tgz", - "integrity": "sha512-UHYyq1MO8GsefGEt7EprS8UrXsm1TxEvFUX1IMTuSLU2Rh7fTIdFtl8xD7JiEYiWU2dl+NYAjCTksTehQUxPag==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.3.tgz", + "integrity": "sha512-QIs2+ArIGQVp5ZYbWD5ZLCY29D5CfWizP8eWnm8FoGD1TX61veauETVQbrV60662V0oFBkrDOuaBI8XgtuyYAQ==", "dev": true, "requires": { - "lodash": "^4.17.11" + "lodash": "^4.17.15" } }, "request-promise-native": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.7.tgz", - "integrity": "sha512-rIMnbBdgNViL37nZ1b3L/VfPOpSi0TqVDQPAvO6U14lMzOLrt5nilxCQqtDKhZeDiW0/hkCXGoQjhgJd/tCh6w==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.8.tgz", + "integrity": "sha512-dapwLGqkHtwL5AEbfenuzjTYg35Jd6KPytsC2/TLkVMz8rm+tNt72MGUWT1RP/aYawMpN6HqbNGBQaRcBtjQMQ==", "dev": true, "requires": { - "request-promise-core": "1.1.2", + "request-promise-core": "1.1.3", "stealthy-require": "^1.1.1", "tough-cookie": "^2.3.3" } @@ -5041,12 +6070,20 @@ "dev": true, "requires": { "resolve-from": "^3.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "dev": true + } } }, "resolve-from": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", - "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, "resolve-url": { @@ -5063,6 +6100,16 @@ "lowercase-keys": "^1.0.0" } }, + "restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "requires": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + } + }, "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", @@ -5077,6 +6124,36 @@ "glob": "^7.1.3" } }, + "rsvp": { + "version": "4.8.5", + "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", + "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", + "dev": true + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } + }, + "run-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz", + "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==", + "dev": true + }, + "rxjs": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", + "integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -5166,6 +6243,12 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=" }, + "semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=", + "dev": true + }, "serve": { "version": "11.2.0", "resolved": "https://registry.npmjs.org/serve/-/serve-11.2.0.tgz", @@ -5318,11 +6401,30 @@ "dev": true }, "slash": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", - "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "dev": true }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + } + } + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -5454,6 +6556,16 @@ "urix": "^0.1.0" } }, + "source-map-support": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz", + "integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "source-map-url": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", @@ -5506,6 +6618,12 @@ "resolved": "https://registry.npmjs.org/splitargs/-/splitargs-0.0.7.tgz", "integrity": "sha1-/p965lc3GzOxDLgNoUPPgknPazs=" }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, "sshpk": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", @@ -5659,6 +6777,58 @@ "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", "dev": true }, + "table": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "tar": { "version": "4.4.13", "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz", @@ -5694,12 +6864,33 @@ "require-main-filename": "^2.0.0" } }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, "throat": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/throat/-/throat-4.1.0.tgz", "integrity": "sha1-iQN8vJLFarGJJua6TLsgDhVnKmo=", "dev": true }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.2" + } + }, "tmpl": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", @@ -5824,6 +7015,21 @@ } } }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "tsutils": { + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", + "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -5846,6 +7052,12 @@ "prelude-ls": "~1.1.2" } }, + "type-fest": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.5.2.tgz", + "integrity": "sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw==", + "dev": true + }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -5858,23 +7070,14 @@ "dev": true }, "uglify-js": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", - "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", + "version": "3.6.8", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.8.tgz", + "integrity": "sha512-XhHJ3S3ZyMwP8kY1Gkugqx3CJh2C3O0y8NPiSxtm1tyD/pktLAkFZsFGpuNfTZddKDQ/bbDBLAd2YyA1pbi8HQ==", "dev": true, "optional": true, "requires": { - "commander": "~2.20.0", + "commander": "~2.20.3", "source-map": "~0.6.1" - }, - "dependencies": { - "commander": { - "version": "2.20.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.1.tgz", - "integrity": "sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg==", - "dev": true, - "optional": true - } } }, "union-value": { @@ -6039,6 +7242,12 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==" }, + "v8-compile-cache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", + "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", + "dev": true + }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -6176,6 +7385,12 @@ "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz", "integrity": "sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY=" }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, "wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", @@ -6196,6 +7411,15 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, "write-file-atomic": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.1.tgz", diff --git a/package.json b/package.json index 9a2e4b2bd..205ca5bfc 100644 --- a/package.json +++ b/package.json @@ -1,43 +1,57 @@ { - "name": "@nodegui/nodegui", - "version": "0.3.1", - "description": "A cross platform library to build native desktop apps.", - "main": "dist/index.js", - "typings": "dist/index.d.ts", - "files": [ - "dist", - "config", - "CMakeLists.txt", - "src/cpp", - "extras/legal", - "plugin" - ], - "author": "Atul R ", - "license": "MIT", - "private": false, - "scripts": { - "dev": "npm run build && qode dist/demo.js", - "postinstall": "npm run build:addon", - "build": "tsc && npm run build:addon", - "build:addon": "cross-env CMAKE_BUILD_PARALLEL_LEVEL=8 cmake-js build", - "test": "qode ./node_modules/.bin/jest" - }, - "dependencies": { - "@nodegui/qode": "^1.0.5", - "cmake-js": "^6.0.0", - "cross-env": "^6.0.0", - "cuid": "^2.1.6", - "node-addon-api": "^1.6.3", - "postcss-nodegui-autoprefixer": "0.0.7" - }, - "devDependencies": { - "@types/bindings": "^1.3.0", - "@types/jest": "^24.0.18", - "@types/node": "^12.0.2", - "jest": "^24.9.0", - "prettier": "^1.17.1", - "serve": "^11.1.0", - "ts-jest": "^24.1.0", - "typescript": "^3.6.3" - } + "name": "@nodegui/nodegui", + "version": "0.3.1", + "description": "A cross platform library to build native desktop apps.", + "main": "dist/index.js", + "typings": "dist/index.d.ts", + "files": [ + "dist", + "config", + "CMakeLists.txt", + "src/cpp", + "extras/legal", + "plugin" + ], + "author": "Atul R ", + "license": "MIT", + "private": false, + "scripts": { + "dev": "npm run build && qode dist/demo.js", + "postinstall": "npm run build:addon", + "build": "tsc && npm run build:addon", + "build:addon": "cross-env CMAKE_BUILD_PARALLEL_LEVEL=8 cmake-js build", + "test": "qode ./node_modules/.bin/jest", + "lint:cpp": "clang-format -i --glob=src/cpp/**/*.[h,c]*", + "lint:ts": "tsc --noEmit && eslint './src/**/*.{ts,tsx}' --fix" + }, + "dependencies": { + "@nodegui/qode": "^1.0.5", + "cmake-js": "^6.0.0", + "cross-env": "^6.0.0", + "cuid": "^2.1.6", + "node-addon-api": "^1.6.3", + "postcss-nodegui-autoprefixer": "0.0.7" + }, + "devDependencies": { + "@types/bindings": "^1.3.0", + "@types/jest": "^24.0.18", + "@types/node": "^12.0.2", + "@typescript-eslint/eslint-plugin": "^2.6.1", + "@typescript-eslint/parser": "^2.6.1", + "clang-format": "^1.3.0", + "eslint": "^6.6.0", + "eslint-config-prettier": "^6.5.0", + "eslint-plugin-prettier": "^3.1.1", + "husky": "^3.0.9", + "jest": "^24.9.0", + "prettier": "^1.18.2", + "serve": "^11.1.0", + "ts-jest": "^24.1.0", + "typescript": "^3.6.3" + }, + "husky": { + "hooks": { + "pre-push": "npm run lint:ts && npm run lint:cpp && npm run test" + } + } } diff --git a/src/cpp/include/deps/spdlog/async.h b/src/cpp/include/deps/spdlog/async.h old mode 100755 new mode 100644 index 971becd70..292e24500 --- a/src/cpp/include/deps/spdlog/async.h +++ b/src/cpp/include/deps/spdlog/async.h @@ -17,13 +17,13 @@ // This is because each message in the queue holds a shared_ptr to the // originating logger. +#include +#include + #include "spdlog/async_logger.h" #include "spdlog/details/registry.h" #include "spdlog/details/thread_pool.h" -#include -#include - namespace spdlog { namespace details { @@ -33,55 +33,56 @@ static const size_t default_async_q_size = 8192; // async logger factory - creates async loggers backed with thread pool. // if a global thread pool doesn't already exist, create it with default queue // size of 8192 items and single thread. -template -struct async_factory_impl -{ - template - static std::shared_ptr create(std::string logger_name, SinkArgs &&... args) - { - auto ®istry_inst = details::registry::instance(); +template +struct async_factory_impl { + template + static std::shared_ptr create(std::string logger_name, + SinkArgs &&... args) { + auto ®istry_inst = details::registry::instance(); - // create global thread pool if not already exists.. - std::lock_guard tp_lock(registry_inst.tp_mutex()); - auto tp = registry_inst.get_tp(); - if (tp == nullptr) - { - tp = std::make_shared(details::default_async_q_size, 1); - registry_inst.set_tp(tp); - } - - auto sink = std::make_shared(std::forward(args)...); - auto new_logger = std::make_shared(std::move(logger_name), std::move(sink), std::move(tp), OverflowPolicy); - registry_inst.initialize_logger(new_logger); - return new_logger; + // create global thread pool if not already exists.. + std::lock_guard tp_lock(registry_inst.tp_mutex()); + auto tp = registry_inst.get_tp(); + if (tp == nullptr) { + tp = std::make_shared(details::default_async_q_size, + 1); + registry_inst.set_tp(tp); } + + auto sink = std::make_shared(std::forward(args)...); + auto new_logger = std::make_shared( + std::move(logger_name), std::move(sink), std::move(tp), OverflowPolicy); + registry_inst.initialize_logger(new_logger); + return new_logger; + } }; using async_factory = async_factory_impl; -using async_factory_nonblock = async_factory_impl; +using async_factory_nonblock = + async_factory_impl; -template -inline std::shared_ptr create_async(std::string logger_name, SinkArgs &&... sink_args) -{ - return async_factory::create(std::move(logger_name), std::forward(sink_args)...); +template +inline std::shared_ptr create_async(std::string logger_name, + SinkArgs &&... sink_args) { + return async_factory::create(std::move(logger_name), + std::forward(sink_args)...); } -template -inline std::shared_ptr create_async_nb(std::string logger_name, SinkArgs &&... sink_args) -{ - return async_factory_nonblock::create(std::move(logger_name), std::forward(sink_args)...); +template +inline std::shared_ptr create_async_nb( + std::string logger_name, SinkArgs &&... sink_args) { + return async_factory_nonblock::create( + std::move(logger_name), std::forward(sink_args)...); } // set global thread pool. -inline void init_thread_pool(size_t q_size, size_t thread_count) -{ - auto tp = std::make_shared(q_size, thread_count); - details::registry::instance().set_tp(std::move(tp)); +inline void init_thread_pool(size_t q_size, size_t thread_count) { + auto tp = std::make_shared(q_size, thread_count); + details::registry::instance().set_tp(std::move(tp)); } // get the global thread pool. -inline std::shared_ptr thread_pool() -{ - return details::registry::instance().get_tp(); +inline std::shared_ptr thread_pool() { + return details::registry::instance().get_tp(); } -} // namespace spdlog +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/async_logger.h b/src/cpp/include/deps/spdlog/async_logger.h old mode 100755 new mode 100644 index a7ecb7873..b2b04038a --- a/src/cpp/include/deps/spdlog/async_logger.h +++ b/src/cpp/include/deps/spdlog/async_logger.h @@ -19,55 +19,60 @@ // Upon destruction, logs all remaining messages in the queue before // destructing.. -#include "spdlog/common.h" -#include "spdlog/logger.h" - #include #include #include +#include "spdlog/common.h" +#include "spdlog/logger.h" + namespace spdlog { // Async overflow policy - block by default. -enum class async_overflow_policy -{ - block, // Block until message can be enqueued - overrun_oldest // Discard oldest message in the queue if full when trying to - // add new item. +enum class async_overflow_policy { + block, // Block until message can be enqueued + overrun_oldest // Discard oldest message in the queue if full when trying to + // add new item. }; namespace details { class thread_pool; } -class async_logger final : public std::enable_shared_from_this, public logger -{ - friend class details::thread_pool; +class async_logger final : public std::enable_shared_from_this, + public logger { + friend class details::thread_pool; -public: - template - async_logger(std::string logger_name, It begin, It end, std::weak_ptr tp, - async_overflow_policy overflow_policy = async_overflow_policy::block); + public: + template + async_logger( + std::string logger_name, It begin, It end, + std::weak_ptr tp, + async_overflow_policy overflow_policy = async_overflow_policy::block); - async_logger(std::string logger_name, sinks_init_list sinks_list, std::weak_ptr tp, - async_overflow_policy overflow_policy = async_overflow_policy::block); + async_logger( + std::string logger_name, sinks_init_list sinks_list, + std::weak_ptr tp, + async_overflow_policy overflow_policy = async_overflow_policy::block); - async_logger(std::string logger_name, sink_ptr single_sink, std::weak_ptr tp, - async_overflow_policy overflow_policy = async_overflow_policy::block); + async_logger( + std::string logger_name, sink_ptr single_sink, + std::weak_ptr tp, + async_overflow_policy overflow_policy = async_overflow_policy::block); - std::shared_ptr clone(std::string new_name) override; + std::shared_ptr clone(std::string new_name) override; -protected: - void sink_it_(details::log_msg &msg) override; - void flush_() override; + protected: + void sink_it_(details::log_msg &msg) override; + void flush_() override; - void backend_log_(const details::log_msg &incoming_log_msg); - void backend_flush_(); + void backend_log_(const details::log_msg &incoming_log_msg); + void backend_flush_(); -private: - std::weak_ptr thread_pool_; - async_overflow_policy overflow_policy_; + private: + std::weak_ptr thread_pool_; + async_overflow_policy overflow_policy_; }; -} // namespace spdlog +} // namespace spdlog #include "details/async_logger_impl.h" diff --git a/src/cpp/include/deps/spdlog/common.h b/src/cpp/include/deps/spdlog/common.h old mode 100755 new mode 100644 index d078a1ab3..77ba0b73e --- a/src/cpp/include/deps/spdlog/common.h +++ b/src/cpp/include/deps/spdlog/common.h @@ -5,26 +5,25 @@ #pragma once -#include "spdlog/tweakme.h" - #include #include +#include #include #include #include #include #include -#include #include #include +#include "spdlog/tweakme.h" + #if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) #include #include #endif #include "spdlog/details/null_mutex.h" - #include "spdlog/fmt/fmt.h" // visual studio upto 2013 does not support noexcept nor constexpr @@ -56,7 +55,7 @@ #define SPDLOG_STRRCHR(str, sep) __builtin_strrchr(str, sep) #else #define SPDLOG_STRRCHR(str, sep) strrchr(str, sep) -#endif //__builtin_strrchr not defined +#endif //__builtin_strrchr not defined #ifdef _WIN32 #define SPDLOG_FILE_BASENAME(file) SPDLOG_STRRCHR("\\" file, '\\') + 1 @@ -108,89 +107,74 @@ using level_t = std::atomic; // Log level enum namespace level { -enum level_enum -{ - trace = SPDLOG_LEVEL_TRACE, - debug = SPDLOG_LEVEL_DEBUG, - info = SPDLOG_LEVEL_INFO, - warn = SPDLOG_LEVEL_WARN, - err = SPDLOG_LEVEL_ERROR, - critical = SPDLOG_LEVEL_CRITICAL, - off = SPDLOG_LEVEL_OFF, +enum level_enum { + trace = SPDLOG_LEVEL_TRACE, + debug = SPDLOG_LEVEL_DEBUG, + info = SPDLOG_LEVEL_INFO, + warn = SPDLOG_LEVEL_WARN, + err = SPDLOG_LEVEL_ERROR, + critical = SPDLOG_LEVEL_CRITICAL, + off = SPDLOG_LEVEL_OFF, }; #if !defined(SPDLOG_LEVEL_NAMES) -#define SPDLOG_LEVEL_NAMES \ - { \ - "trace", "debug", "info", "warning", "error", "critical", "off" \ - } +#define SPDLOG_LEVEL_NAMES \ + { "trace", "debug", "info", "warning", "error", "critical", "off" } #endif static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES; static const char *short_level_names[]{"T", "D", "I", "W", "E", "C", "O"}; -inline string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT -{ - return level_string_views[l]; +inline string_view_t &to_string_view(spdlog::level::level_enum l) + SPDLOG_NOEXCEPT { + return level_string_views[l]; } -inline const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT -{ - return short_level_names[l]; +inline const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT { + return short_level_names[l]; } -inline spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT -{ - int level = 0; - for (const auto &level_str : level_string_views) - { - if (level_str == name) - { - return static_cast(level); - } - level++; +inline spdlog::level::level_enum from_str(const std::string &name) + SPDLOG_NOEXCEPT { + int level = 0; + for (const auto &level_str : level_string_views) { + if (level_str == name) { + return static_cast(level); } - return level::off; + level++; + } + return level::off; } using level_hasher = std::hash; -} // namespace level +} // namespace level // // Pattern time - specific time getting to use for pattern_formatter. // local time by default // -enum class pattern_time_type -{ - local, // log localtime - utc // log utc +enum class pattern_time_type { + local, // log localtime + utc // log utc }; // // Log exception // -class spdlog_ex : public std::exception -{ -public: - explicit spdlog_ex(std::string msg) - : msg_(std::move(msg)) - { - } +class spdlog_ex : public std::exception { + public: + explicit spdlog_ex(std::string msg) : msg_(std::move(msg)) {} - spdlog_ex(const std::string &msg, int last_errno) - { - fmt::memory_buffer outbuf; - fmt::format_system_error(outbuf, last_errno, msg); - msg_ = fmt::to_string(outbuf); - } + spdlog_ex(const std::string &msg, int last_errno) { + fmt::memory_buffer outbuf; + fmt::format_system_error(outbuf, last_errno, msg); + msg_ = fmt::to_string(outbuf); + } - const char *what() const SPDLOG_NOEXCEPT override - { - return msg_.c_str(); - } + const char *what() const SPDLOG_NOEXCEPT override { return msg_.c_str(); } -private: - std::string msg_; + private: + std::string msg_; }; // @@ -202,42 +186,31 @@ using filename_t = std::wstring; using filename_t = std::string; #endif -struct source_loc -{ - SPDLOG_CONSTEXPR source_loc() - : filename{""} - , line{0} - , funcname{""} - { - } - SPDLOG_CONSTEXPR source_loc(const char *filename, int line, const char *funcname) - : filename{filename} - , line{static_cast(line)} - , funcname{funcname} - { - } +struct source_loc { + SPDLOG_CONSTEXPR source_loc() : filename{""}, line{0}, funcname{""} {} + SPDLOG_CONSTEXPR source_loc(const char *filename, int line, + const char *funcname) + : filename{filename}, + line{static_cast(line)}, + funcname{funcname} {} - SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT - { - return line == 0; - } - const char *filename; - uint32_t line; - const char *funcname; + SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT { return line == 0; } + const char *filename; + uint32_t line; + const char *funcname; }; namespace details { // make_unique support for pre c++14 -#if __cplusplus >= 201402L // C++14 and beyond +#if __cplusplus >= 201402L // C++14 and beyond using std::make_unique; #else -template -std::unique_ptr make_unique(Args &&... args) -{ - static_assert(!std::is_array::value, "arrays not supported"); - return std::unique_ptr(new T(std::forward(args)...)); +template +std::unique_ptr make_unique(Args &&... args) { + static_assert(!std::is_array::value, "arrays not supported"); + return std::unique_ptr(new T(std::forward(args)...)); } #endif -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/async_logger_impl.h b/src/cpp/include/deps/spdlog/details/async_logger_impl.h old mode 100755 new mode 100644 index aafcae656..a389583b2 --- a/src/cpp/include/deps/spdlog/details/async_logger_impl.h +++ b/src/cpp/include/deps/spdlog/details/async_logger_impl.h @@ -8,103 +8,92 @@ // async logger implementation // uses a thread pool to perform the actual logging -#include "spdlog/details/thread_pool.h" - #include #include #include -template +#include "spdlog/details/thread_pool.h" + +template inline spdlog::async_logger::async_logger( - std::string logger_name, It begin, It end, std::weak_ptr tp, async_overflow_policy overflow_policy) - : logger(std::move(logger_name), begin, end) - , thread_pool_(std::move(tp)) - , overflow_policy_(overflow_policy) -{ -} + std::string logger_name, It begin, It end, + std::weak_ptr tp, + async_overflow_policy overflow_policy) + : logger(std::move(logger_name), begin, end), + thread_pool_(std::move(tp)), + overflow_policy_(overflow_policy) {} inline spdlog::async_logger::async_logger( - std::string logger_name, sinks_init_list sinks_list, std::weak_ptr tp, async_overflow_policy overflow_policy) - : async_logger(std::move(logger_name), sinks_list.begin(), sinks_list.end(), std::move(tp), overflow_policy) -{ -} + std::string logger_name, sinks_init_list sinks_list, + std::weak_ptr tp, + async_overflow_policy overflow_policy) + : async_logger(std::move(logger_name), sinks_list.begin(), sinks_list.end(), + std::move(tp), overflow_policy) {} inline spdlog::async_logger::async_logger( - std::string logger_name, sink_ptr single_sink, std::weak_ptr tp, async_overflow_policy overflow_policy) - : async_logger(std::move(logger_name), {std::move(single_sink)}, std::move(tp), overflow_policy) -{ -} + std::string logger_name, sink_ptr single_sink, + std::weak_ptr tp, + async_overflow_policy overflow_policy) + : async_logger(std::move(logger_name), {std::move(single_sink)}, + std::move(tp), overflow_policy) {} // send the log message to the thread pool -inline void spdlog::async_logger::sink_it_(details::log_msg &msg) -{ +inline void spdlog::async_logger::sink_it_(details::log_msg &msg) { #if defined(SPDLOG_ENABLE_MESSAGE_COUNTER) - incr_msg_counter_(msg); + incr_msg_counter_(msg); #endif - if (auto pool_ptr = thread_pool_.lock()) - { - pool_ptr->post_log(shared_from_this(), msg, overflow_policy_); - } - else - { - throw spdlog_ex("async log: thread pool doesn't exist anymore"); - } + if (auto pool_ptr = thread_pool_.lock()) { + pool_ptr->post_log(shared_from_this(), msg, overflow_policy_); + } else { + throw spdlog_ex("async log: thread pool doesn't exist anymore"); + } } // send flush request to the thread pool -inline void spdlog::async_logger::flush_() -{ - if (auto pool_ptr = thread_pool_.lock()) - { - pool_ptr->post_flush(shared_from_this(), overflow_policy_); - } - else - { - throw spdlog_ex("async flush: thread pool doesn't exist anymore"); - } +inline void spdlog::async_logger::flush_() { + if (auto pool_ptr = thread_pool_.lock()) { + pool_ptr->post_flush(shared_from_this(), overflow_policy_); + } else { + throw spdlog_ex("async flush: thread pool doesn't exist anymore"); + } } // // backend functions - called from the thread pool to do the actual job // -inline void spdlog::async_logger::backend_log_(const details::log_msg &incoming_log_msg) -{ - try - { - for (auto &s : sinks_) - { - if (s->should_log(incoming_log_msg.level)) - { - s->log(incoming_log_msg); - } - } +inline void spdlog::async_logger::backend_log_( + const details::log_msg &incoming_log_msg) { + try { + for (auto &s : sinks_) { + if (s->should_log(incoming_log_msg.level)) { + s->log(incoming_log_msg); + } } - SPDLOG_CATCH_AND_HANDLE + } + SPDLOG_CATCH_AND_HANDLE - if (should_flush_(incoming_log_msg)) - { - backend_flush_(); - } + if (should_flush_(incoming_log_msg)) { + backend_flush_(); + } } -inline void spdlog::async_logger::backend_flush_() -{ - try - { - for (auto &sink : sinks_) - { - sink->flush(); - } +inline void spdlog::async_logger::backend_flush_() { + try { + for (auto &sink : sinks_) { + sink->flush(); } - SPDLOG_CATCH_AND_HANDLE + } + SPDLOG_CATCH_AND_HANDLE } -inline std::shared_ptr spdlog::async_logger::clone(std::string new_name) -{ - auto cloned = std::make_shared(std::move(new_name), sinks_.begin(), sinks_.end(), thread_pool_, overflow_policy_); +inline std::shared_ptr spdlog::async_logger::clone( + std::string new_name) { + auto cloned = std::make_shared( + std::move(new_name), sinks_.begin(), sinks_.end(), thread_pool_, + overflow_policy_); - cloned->set_level(this->level()); - cloned->flush_on(this->flush_level()); - cloned->set_error_handler(this->error_handler()); - return std::move(cloned); + cloned->set_level(this->level()); + cloned->flush_on(this->flush_level()); + cloned->set_error_handler(this->error_handler()); + return std::move(cloned); } diff --git a/src/cpp/include/deps/spdlog/details/circular_q.h b/src/cpp/include/deps/spdlog/details/circular_q.h old mode 100755 new mode 100644 index b01325bb7..273cd3782 --- a/src/cpp/include/deps/spdlog/details/circular_q.h +++ b/src/cpp/include/deps/spdlog/details/circular_q.h @@ -10,63 +10,52 @@ namespace spdlog { namespace details { -template -class circular_q -{ -public: - using item_type = T; +template +class circular_q { + public: + using item_type = T; - explicit circular_q(size_t max_items) - : max_items_(max_items + 1) // one item is reserved as marker for full q - , v_(max_items_) + explicit circular_q(size_t max_items) + : max_items_(max_items + 1) // one item is reserved as marker for full q + , + v_(max_items_) {} + + // push back, overrun (oldest) item if no room left + void push_back(T &&item) { + v_[tail_] = std::move(item); + tail_ = (tail_ + 1) % max_items_; + + if (tail_ == head_) // overrun last item if full { + head_ = (head_ + 1) % max_items_; + ++overrun_counter_; } + } - // push back, overrun (oldest) item if no room left - void push_back(T &&item) - { - v_[tail_] = std::move(item); - tail_ = (tail_ + 1) % max_items_; + // Pop item from front. + // If there are no elements in the container, the behavior is undefined. + void pop_front(T &popped_item) { + popped_item = std::move(v_[head_]); + head_ = (head_ + 1) % max_items_; + } - if (tail_ == head_) // overrun last item if full - { - head_ = (head_ + 1) % max_items_; - ++overrun_counter_; - } - } + bool empty() { return tail_ == head_; } - // Pop item from front. - // If there are no elements in the container, the behavior is undefined. - void pop_front(T &popped_item) - { - popped_item = std::move(v_[head_]); - head_ = (head_ + 1) % max_items_; - } + bool full() { + // head is ahead of the tail by 1 + return ((tail_ + 1) % max_items_) == head_; + } - bool empty() - { - return tail_ == head_; - } + size_t overrun_counter() const { return overrun_counter_; } - bool full() - { - // head is ahead of the tail by 1 - return ((tail_ + 1) % max_items_) == head_; - } + private: + size_t max_items_; + typename std::vector::size_type head_ = 0; + typename std::vector::size_type tail_ = 0; - size_t overrun_counter() const - { - return overrun_counter_; - } + std::vector v_; -private: - size_t max_items_; - typename std::vector::size_type head_ = 0; - typename std::vector::size_type tail_ = 0; - - std::vector v_; - - size_t overrun_counter_ = 0; + size_t overrun_counter_ = 0; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/console_globals.h b/src/cpp/include/deps/spdlog/details/console_globals.h old mode 100755 new mode 100644 index e2afb6bf0..a433d8b70 --- a/src/cpp/include/deps/spdlog/details/console_globals.h +++ b/src/cpp/include/deps/spdlog/details/console_globals.h @@ -4,14 +4,15 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) // -#include "spdlog/details/null_mutex.h" #include #include +#include "spdlog/details/null_mutex.h" + #ifdef _WIN32 #ifndef NOMINMAX -#define NOMINMAX // prevent windows redefining min/max +#define NOMINMAX // prevent windows redefining min/max #endif #ifndef WIN32_LEAN_AND_MEAN @@ -23,52 +24,34 @@ namespace spdlog { namespace details { -struct console_stdout -{ - static std::FILE *stream() - { - return stdout; - } +struct console_stdout { + static std::FILE *stream() { return stdout; } #ifdef _WIN32 - static HANDLE handle() - { - return ::GetStdHandle(STD_OUTPUT_HANDLE); - } + static HANDLE handle() { return ::GetStdHandle(STD_OUTPUT_HANDLE); } #endif }; -struct console_stderr -{ - static std::FILE *stream() - { - return stderr; - } +struct console_stderr { + static std::FILE *stream() { return stderr; } #ifdef _WIN32 - static HANDLE handle() - { - return ::GetStdHandle(STD_ERROR_HANDLE); - } + static HANDLE handle() { return ::GetStdHandle(STD_ERROR_HANDLE); } #endif }; -struct console_mutex -{ - using mutex_t = std::mutex; - static mutex_t &mutex() - { - static mutex_t s_mutex; - return s_mutex; - } +struct console_mutex { + using mutex_t = std::mutex; + static mutex_t &mutex() { + static mutex_t s_mutex; + return s_mutex; + } }; -struct console_nullmutex -{ - using mutex_t = null_mutex; - static mutex_t &mutex() - { - static mutex_t s_mutex; - return s_mutex; - } +struct console_nullmutex { + using mutex_t = null_mutex; + static mutex_t &mutex() { + static mutex_t s_mutex; + return s_mutex; + } }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/file_helper.h b/src/cpp/include/deps/spdlog/details/file_helper.h old mode 100755 new mode 100644 index 8c1132d9c..ada5e2fb1 --- a/src/cpp/include/deps/spdlog/details/file_helper.h +++ b/src/cpp/include/deps/spdlog/details/file_helper.h @@ -6,11 +6,8 @@ #pragma once // Helper class for file sinks. -// When failing to open a file, retry several times(5) with a delay interval(10 ms). -// Throw spdlog_ex exception on errors. - -#include "spdlog/details/log_msg.h" -#include "spdlog/details/os.h" +// When failing to open a file, retry several times(5) with a delay interval(10 +// ms). Throw spdlog_ex exception on errors. #include #include @@ -19,134 +16,117 @@ #include #include +#include "spdlog/details/log_msg.h" +#include "spdlog/details/os.h" + namespace spdlog { namespace details { -class file_helper -{ +class file_helper { + public: + const int open_tries = 5; + const int open_interval = 10; -public: - const int open_tries = 5; - const int open_interval = 10; + explicit file_helper() = default; - explicit file_helper() = default; + file_helper(const file_helper &) = delete; + file_helper &operator=(const file_helper &) = delete; - file_helper(const file_helper &) = delete; - file_helper &operator=(const file_helper &) = delete; + ~file_helper() { close(); } - ~file_helper() - { - close(); + void open(const filename_t &fname, bool truncate = false) { + close(); + auto *mode = truncate ? SPDLOG_FILENAME_T("wb") : SPDLOG_FILENAME_T("ab"); + _filename = fname; + for (int tries = 0; tries < open_tries; ++tries) { + if (!os::fopen_s(&fd_, fname, mode)) { + return; + } + + details::os::sleep_for_millis(open_interval); } - void open(const filename_t &fname, bool truncate = false) - { - close(); - auto *mode = truncate ? SPDLOG_FILENAME_T("wb") : SPDLOG_FILENAME_T("ab"); - _filename = fname; - for (int tries = 0; tries < open_tries; ++tries) - { - if (!os::fopen_s(&fd_, fname, mode)) - { - return; - } + throw spdlog_ex("Failed opening file " + os::filename_to_str(_filename) + + " for writing", + errno); + } - details::os::sleep_for_millis(open_interval); - } + void reopen(bool truncate) { + if (_filename.empty()) { + throw spdlog_ex("Failed re opening file - was not opened before"); + } + open(_filename, truncate); + } - throw spdlog_ex("Failed opening file " + os::filename_to_str(_filename) + " for writing", errno); + void flush() { std::fflush(fd_); } + + void close() { + if (fd_ != nullptr) { + std::fclose(fd_); + fd_ = nullptr; + } + } + + void write(const fmt::memory_buffer &buf) { + size_t msg_size = buf.size(); + auto data = buf.data(); + if (std::fwrite(data, 1, msg_size, fd_) != msg_size) { + throw spdlog_ex( + "Failed writing to file " + os::filename_to_str(_filename), errno); + } + } + + size_t size() const { + if (fd_ == nullptr) { + throw spdlog_ex("Cannot use size() on closed file " + + os::filename_to_str(_filename)); + } + return os::filesize(fd_); + } + + const filename_t &filename() const { return _filename; } + + static bool file_exists(const filename_t &fname) { + return os::file_exists(fname); + } + + // + // return file path and its extension: + // + // "mylog.txt" => ("mylog", ".txt") + // "mylog" => ("mylog", "") + // "mylog." => ("mylog.", "") + // "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt") + // + // the starting dot in filenames is ignored (hidden files): + // + // ".mylog" => (".mylog". "") + // "my_folder/.mylog" => ("my_folder/.mylog", "") + // "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt") + static std::tuple split_by_extension( + const spdlog::filename_t &fname) { + auto ext_index = fname.rfind('.'); + + // no valid extension found - return whole path and empty string as + // extension + if (ext_index == filename_t::npos || ext_index == 0 || + ext_index == fname.size() - 1) { + return std::make_tuple(fname, spdlog::filename_t()); } - void reopen(bool truncate) - { - if (_filename.empty()) - { - throw spdlog_ex("Failed re opening file - was not opened before"); - } - open(_filename, truncate); + // treat casese like "/etc/rc.d/somelogfile or "/abc/.hiddenfile" + auto folder_index = fname.rfind(details::os::folder_sep); + if (folder_index != filename_t::npos && folder_index >= ext_index - 1) { + return std::make_tuple(fname, spdlog::filename_t()); } - void flush() - { - std::fflush(fd_); - } + // finally - return a valid base and extension tuple + return std::make_tuple(fname.substr(0, ext_index), fname.substr(ext_index)); + } - void close() - { - if (fd_ != nullptr) - { - std::fclose(fd_); - fd_ = nullptr; - } - } - - void write(const fmt::memory_buffer &buf) - { - size_t msg_size = buf.size(); - auto data = buf.data(); - if (std::fwrite(data, 1, msg_size, fd_) != msg_size) - { - throw spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno); - } - } - - size_t size() const - { - if (fd_ == nullptr) - { - throw spdlog_ex("Cannot use size() on closed file " + os::filename_to_str(_filename)); - } - return os::filesize(fd_); - } - - const filename_t &filename() const - { - return _filename; - } - - static bool file_exists(const filename_t &fname) - { - return os::file_exists(fname); - } - - // - // return file path and its extension: - // - // "mylog.txt" => ("mylog", ".txt") - // "mylog" => ("mylog", "") - // "mylog." => ("mylog.", "") - // "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt") - // - // the starting dot in filenames is ignored (hidden files): - // - // ".mylog" => (".mylog". "") - // "my_folder/.mylog" => ("my_folder/.mylog", "") - // "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt") - static std::tuple split_by_extension(const spdlog::filename_t &fname) - { - auto ext_index = fname.rfind('.'); - - // no valid extension found - return whole path and empty string as - // extension - if (ext_index == filename_t::npos || ext_index == 0 || ext_index == fname.size() - 1) - { - return std::make_tuple(fname, spdlog::filename_t()); - } - - // treat casese like "/etc/rc.d/somelogfile or "/abc/.hiddenfile" - auto folder_index = fname.rfind(details::os::folder_sep); - if (folder_index != filename_t::npos && folder_index >= ext_index - 1) - { - return std::make_tuple(fname, spdlog::filename_t()); - } - - // finally - return a valid base and extension tuple - return std::make_tuple(fname.substr(0, ext_index), fname.substr(ext_index)); - } - -private: - std::FILE *fd_{nullptr}; - filename_t _filename; + private: + std::FILE *fd_{nullptr}; + filename_t _filename; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/fmt_helper.h b/src/cpp/include/deps/spdlog/details/fmt_helper.h old mode 100755 new mode 100644 index d76aac452..f22b49f9a --- a/src/cpp/include/deps/spdlog/details/fmt_helper.h +++ b/src/cpp/include/deps/spdlog/details/fmt_helper.h @@ -6,6 +6,7 @@ #include #include + #include "spdlog/fmt/fmt.h" // Some fmt helpers to efficiently format and pad ints and strings @@ -13,110 +14,100 @@ namespace spdlog { namespace details { namespace fmt_helper { -template -inline spdlog::string_view_t to_string_view(const fmt::basic_memory_buffer &buf) SPDLOG_NOEXCEPT -{ - return spdlog::string_view_t(buf.data(), buf.size()); +template +inline spdlog::string_view_t to_string_view( + const fmt::basic_memory_buffer &buf) SPDLOG_NOEXCEPT { + return spdlog::string_view_t(buf.data(), buf.size()); } -template -inline void append_buf(const fmt::basic_memory_buffer &buf, fmt::basic_memory_buffer &dest) -{ - auto *buf_ptr = buf.data(); - dest.append(buf_ptr, buf_ptr + buf.size()); +template +inline void append_buf(const fmt::basic_memory_buffer &buf, + fmt::basic_memory_buffer &dest) { + auto *buf_ptr = buf.data(); + dest.append(buf_ptr, buf_ptr + buf.size()); } -template -inline void append_string_view(spdlog::string_view_t view, fmt::basic_memory_buffer &dest) -{ - auto *buf_ptr = view.data(); - if (buf_ptr != nullptr) - { - dest.append(buf_ptr, buf_ptr + view.size()); - } +template +inline void append_string_view( + spdlog::string_view_t view, + fmt::basic_memory_buffer &dest) { + auto *buf_ptr = view.data(); + if (buf_ptr != nullptr) { + dest.append(buf_ptr, buf_ptr + view.size()); + } } -template -inline void append_int(T n, fmt::basic_memory_buffer &dest) -{ - fmt::format_int i(n); - dest.append(i.data(), i.data() + i.size()); +template +inline void append_int(T n, fmt::basic_memory_buffer &dest) { + fmt::format_int i(n); + dest.append(i.data(), i.data() + i.size()); } -template -inline unsigned count_digits(T n) -{ - using count_type = typename std::conditional<(sizeof(T) > sizeof(uint32_t)), uint64_t, uint32_t>::type; - return static_cast(fmt::internal::count_digits(static_cast(n))); +template +inline unsigned count_digits(T n) { + using count_type = typename std::conditional<(sizeof(T) > sizeof(uint32_t)), + uint64_t, uint32_t>::type; + return static_cast( + fmt::internal::count_digits(static_cast(n))); } -template -inline void pad2(int n, fmt::basic_memory_buffer &dest) -{ - if (n > 99) - { - append_int(n, dest); - } - else if (n > 9) // 10-99 - { - dest.push_back(static_cast('0' + n / 10)); - dest.push_back(static_cast('0' + n % 10)); - } - else if (n >= 0) // 0-9 - { - dest.push_back('0'); - dest.push_back(static_cast('0' + n)); - } - else // negatives (unlikely, but just in case, let fmt deal with it) - { - fmt::format_to(dest, "{:02}", n); - } -} - -template -inline void pad_uint(T n, unsigned int width, fmt::basic_memory_buffer &dest) -{ - static_assert(std::is_unsigned::value, "pad_uint must get unsigned T"); - auto digits = count_digits(n); - if (width > digits) - { - const char *zeroes = "0000000000000000000"; - dest.append(zeroes, zeroes + width - digits); - } +template +inline void pad2(int n, fmt::basic_memory_buffer &dest) { + if (n > 99) { append_int(n, dest); + } else if (n > 9) // 10-99 + { + dest.push_back(static_cast('0' + n / 10)); + dest.push_back(static_cast('0' + n % 10)); + } else if (n >= 0) // 0-9 + { + dest.push_back('0'); + dest.push_back(static_cast('0' + n)); + } else // negatives (unlikely, but just in case, let fmt deal with it) + { + fmt::format_to(dest, "{:02}", n); + } } -template -inline void pad3(T n, fmt::basic_memory_buffer &dest) -{ - pad_uint(n, 3, dest); +template +inline void pad_uint(T n, unsigned int width, + fmt::basic_memory_buffer &dest) { + static_assert(std::is_unsigned::value, "pad_uint must get unsigned T"); + auto digits = count_digits(n); + if (width > digits) { + const char *zeroes = "0000000000000000000"; + dest.append(zeroes, zeroes + width - digits); + } + append_int(n, dest); } -template -inline void pad6(T n, fmt::basic_memory_buffer &dest) -{ - pad_uint(n, 6, dest); +template +inline void pad3(T n, fmt::basic_memory_buffer &dest) { + pad_uint(n, 3, dest); } -template -inline void pad9(T n, fmt::basic_memory_buffer &dest) -{ - pad_uint(n, 9, dest); +template +inline void pad6(T n, fmt::basic_memory_buffer &dest) { + pad_uint(n, 6, dest); +} + +template +inline void pad9(T n, fmt::basic_memory_buffer &dest) { + pad_uint(n, 9, dest); } // return fraction of a second of the given time_point. // e.g. // fraction(tp) -> will return the millis part of the second -template -inline ToDuration time_fraction(const log_clock::time_point &tp) -{ - using std::chrono::duration_cast; - using std::chrono::seconds; - auto duration = tp.time_since_epoch(); - auto secs = duration_cast(duration); - return duration_cast(duration) - duration_cast(secs); +template +inline ToDuration time_fraction(const log_clock::time_point &tp) { + using std::chrono::duration_cast; + using std::chrono::seconds; + auto duration = tp.time_since_epoch(); + auto secs = duration_cast(duration); + return duration_cast(duration) - duration_cast(secs); } -} // namespace fmt_helper -} // namespace details -} // namespace spdlog +} // namespace fmt_helper +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/log_msg.h b/src/cpp/include/deps/spdlog/details/log_msg.h old mode 100755 new mode 100644 index 69422ba37..595302303 --- a/src/cpp/include/deps/spdlog/details/log_msg.h +++ b/src/cpp/include/deps/spdlog/details/log_msg.h @@ -5,51 +5,51 @@ #pragma once -#include "spdlog/common.h" -#include "spdlog/details/os.h" - #include #include +#include "spdlog/common.h" +#include "spdlog/details/os.h" + namespace spdlog { namespace details { -struct log_msg -{ - - log_msg(source_loc loc, const std::string *loggers_name, level::level_enum lvl, string_view_t view) - : logger_name(loggers_name) - , level(lvl) +struct log_msg { + log_msg(source_loc loc, const std::string *loggers_name, + level::level_enum lvl, string_view_t view) + : logger_name(loggers_name), + level(lvl) #ifndef SPDLOG_NO_DATETIME - , time(os::now()) + , + time(os::now()) #endif #ifndef SPDLOG_NO_THREAD_ID - , thread_id(os::thread_id()) + , + thread_id(os::thread_id()) #endif - , source(loc) - , payload(view) - { - } + , + source(loc), + payload(view) { + } - log_msg(const std::string *loggers_name, level::level_enum lvl, string_view_t view) - : log_msg(source_loc{}, loggers_name, lvl, view) - { - } + log_msg(const std::string *loggers_name, level::level_enum lvl, + string_view_t view) + : log_msg(source_loc{}, loggers_name, lvl, view) {} - log_msg(const log_msg &other) = default; + log_msg(const log_msg &other) = default; - const std::string *logger_name{nullptr}; - level::level_enum level{level::off}; - log_clock::time_point time; - size_t thread_id{0}; - size_t msg_id{0}; + const std::string *logger_name{nullptr}; + level::level_enum level{level::off}; + log_clock::time_point time; + size_t thread_id{0}; + size_t msg_id{0}; - // wrapping the formatted text with color (updated by pattern_formatter). - mutable size_t color_range_start{0}; - mutable size_t color_range_end{0}; + // wrapping the formatted text with color (updated by pattern_formatter). + mutable size_t color_range_start{0}; + mutable size_t color_range_end{0}; - source_loc source; - const string_view_t payload; + source_loc source; + const string_view_t payload; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/logger_impl.h b/src/cpp/include/deps/spdlog/details/logger_impl.h old mode 100755 new mode 100644 index 0212ede53..756acc99b --- a/src/cpp/include/deps/spdlog/details/logger_impl.h +++ b/src/cpp/include/deps/spdlog/details/logger_impl.h @@ -5,437 +5,385 @@ #pragma once -#include "spdlog/details/fmt_helper.h" - #include #include -#define SPDLOG_CATCH_AND_HANDLE \ - catch (const std::exception &ex) \ - { \ - err_handler_(ex.what()); \ - } \ - catch (...) \ - { \ - err_handler_("Unknown exception in logger"); \ - } +#include "spdlog/details/fmt_helper.h" + +#define SPDLOG_CATCH_AND_HANDLE \ + catch (const std::exception &ex) { \ + err_handler_(ex.what()); \ + } \ + catch (...) { \ + err_handler_("Unknown exception in logger"); \ + } // create logger with given name, sinks and the default pattern formatter // all other ctors will call this one -template +template inline spdlog::logger::logger(std::string logger_name, It begin, It end) - : name_(std::move(logger_name)) - , sinks_(begin, end) -{ -} + : name_(std::move(logger_name)), sinks_(begin, end) {} // ctor with sinks as init list -inline spdlog::logger::logger(std::string logger_name, sinks_init_list sinks_list) - : logger(std::move(logger_name), sinks_list.begin(), sinks_list.end()) -{ -} +inline spdlog::logger::logger(std::string logger_name, + sinks_init_list sinks_list) + : logger(std::move(logger_name), sinks_list.begin(), sinks_list.end()) {} // ctor with single sink -inline spdlog::logger::logger(std::string logger_name, spdlog::sink_ptr single_sink) - : logger(std::move(logger_name), {std::move(single_sink)}) -{ -} +inline spdlog::logger::logger(std::string logger_name, + spdlog::sink_ptr single_sink) + : logger(std::move(logger_name), {std::move(single_sink)}) {} inline spdlog::logger::~logger() = default; -inline void spdlog::logger::set_formatter(std::unique_ptr f) -{ - for (auto &sink : sinks_) - { - sink->set_formatter(f->clone()); - } +inline void spdlog::logger::set_formatter( + std::unique_ptr f) { + for (auto &sink : sinks_) { + sink->set_formatter(f->clone()); + } } -inline void spdlog::logger::set_pattern(std::string pattern, pattern_time_type time_type) -{ - auto new_formatter = details::make_unique(std::move(pattern), time_type); - set_formatter(std::move(new_formatter)); +inline void spdlog::logger::set_pattern(std::string pattern, + pattern_time_type time_type) { + auto new_formatter = details::make_unique( + std::move(pattern), time_type); + set_formatter(std::move(new_formatter)); } -template -inline void spdlog::logger::log(source_loc source, level::level_enum lvl, const char *fmt, const Args &... args) -{ - if (!should_log(lvl)) - { - return; - } +template +inline void spdlog::logger::log(source_loc source, level::level_enum lvl, + const char *fmt, const Args &... args) { + if (!should_log(lvl)) { + return; + } - try - { - using details::fmt_helper::to_string_view; - fmt::memory_buffer buf; - fmt::format_to(buf, fmt, args...); - details::log_msg log_msg(source, &name_, lvl, to_string_view(buf)); - sink_it_(log_msg); - } - SPDLOG_CATCH_AND_HANDLE + try { + using details::fmt_helper::to_string_view; + fmt::memory_buffer buf; + fmt::format_to(buf, fmt, args...); + details::log_msg log_msg(source, &name_, lvl, to_string_view(buf)); + sink_it_(log_msg); + } + SPDLOG_CATCH_AND_HANDLE } -template -inline void spdlog::logger::log(level::level_enum lvl, const char *fmt, const Args &... args) -{ - log(source_loc{}, lvl, fmt, args...); +template +inline void spdlog::logger::log(level::level_enum lvl, const char *fmt, + const Args &... args) { + log(source_loc{}, lvl, fmt, args...); } -inline void spdlog::logger::log(source_loc source, level::level_enum lvl, const char *msg) -{ - if (!should_log(lvl)) - { - return; - } +inline void spdlog::logger::log(source_loc source, level::level_enum lvl, + const char *msg) { + if (!should_log(lvl)) { + return; + } - try - { - details::log_msg log_msg(source, &name_, lvl, spdlog::string_view_t(msg)); - sink_it_(log_msg); - } - SPDLOG_CATCH_AND_HANDLE + try { + details::log_msg log_msg(source, &name_, lvl, spdlog::string_view_t(msg)); + sink_it_(log_msg); + } + SPDLOG_CATCH_AND_HANDLE } -inline void spdlog::logger::log(level::level_enum lvl, const char *msg) -{ - log(source_loc{}, lvl, msg); +inline void spdlog::logger::log(level::level_enum lvl, const char *msg) { + log(source_loc{}, lvl, msg); } -template::value, T>::type *> -inline void spdlog::logger::log(source_loc source, level::level_enum lvl, const T &msg) -{ - if (!should_log(lvl)) - { - return; - } - try - { - details::log_msg log_msg(source, &name_, lvl, msg); - sink_it_(log_msg); - } - SPDLOG_CATCH_AND_HANDLE +template ::value, T>::type *> +inline void spdlog::logger::log(source_loc source, level::level_enum lvl, + const T &msg) { + if (!should_log(lvl)) { + return; + } + try { + details::log_msg log_msg(source, &name_, lvl, msg); + sink_it_(log_msg); + } + SPDLOG_CATCH_AND_HANDLE } -template::value, T>::type *> -inline void spdlog::logger::log(level::level_enum lvl, const T &msg) -{ - log(source_loc{}, lvl, msg); +template ::value, T>::type *> +inline void spdlog::logger::log(level::level_enum lvl, const T &msg) { + log(source_loc{}, lvl, msg); } -template::value, T>::type *> -inline void spdlog::logger::log(source_loc source, level::level_enum lvl, const T &msg) -{ - if (!should_log(lvl)) - { - return; - } - try - { - using details::fmt_helper::to_string_view; - fmt::memory_buffer buf; - fmt::format_to(buf, "{}", msg); - details::log_msg log_msg(source, &name_, lvl, to_string_view(buf)); - sink_it_(log_msg); - } - SPDLOG_CATCH_AND_HANDLE +template ::value, T>::type *> +inline void spdlog::logger::log(source_loc source, level::level_enum lvl, + const T &msg) { + if (!should_log(lvl)) { + return; + } + try { + using details::fmt_helper::to_string_view; + fmt::memory_buffer buf; + fmt::format_to(buf, "{}", msg); + details::log_msg log_msg(source, &name_, lvl, to_string_view(buf)); + sink_it_(log_msg); + } + SPDLOG_CATCH_AND_HANDLE } -template::value, T>::type *> -inline void spdlog::logger::log(level::level_enum lvl, const T &msg) -{ - log(source_loc{}, lvl, msg); +template ::value, T>::type *> +inline void spdlog::logger::log(level::level_enum lvl, const T &msg) { + log(source_loc{}, lvl, msg); } -template -inline void spdlog::logger::trace(const char *fmt, const Args &... args) -{ - log(level::trace, fmt, args...); +template +inline void spdlog::logger::trace(const char *fmt, const Args &... args) { + log(level::trace, fmt, args...); } -template -inline void spdlog::logger::debug(const char *fmt, const Args &... args) -{ - log(level::debug, fmt, args...); +template +inline void spdlog::logger::debug(const char *fmt, const Args &... args) { + log(level::debug, fmt, args...); } -template -inline void spdlog::logger::info(const char *fmt, const Args &... args) -{ - log(level::info, fmt, args...); +template +inline void spdlog::logger::info(const char *fmt, const Args &... args) { + log(level::info, fmt, args...); } -template -inline void spdlog::logger::warn(const char *fmt, const Args &... args) -{ - log(level::warn, fmt, args...); +template +inline void spdlog::logger::warn(const char *fmt, const Args &... args) { + log(level::warn, fmt, args...); } -template -inline void spdlog::logger::error(const char *fmt, const Args &... args) -{ - log(level::err, fmt, args...); +template +inline void spdlog::logger::error(const char *fmt, const Args &... args) { + log(level::err, fmt, args...); } -template -inline void spdlog::logger::critical(const char *fmt, const Args &... args) -{ - log(level::critical, fmt, args...); +template +inline void spdlog::logger::critical(const char *fmt, const Args &... args) { + log(level::critical, fmt, args...); } -template -inline void spdlog::logger::trace(const T &msg) -{ - log(level::trace, msg); +template +inline void spdlog::logger::trace(const T &msg) { + log(level::trace, msg); } -template -inline void spdlog::logger::debug(const T &msg) -{ - log(level::debug, msg); +template +inline void spdlog::logger::debug(const T &msg) { + log(level::debug, msg); } -template -inline void spdlog::logger::info(const T &msg) -{ - log(level::info, msg); +template +inline void spdlog::logger::info(const T &msg) { + log(level::info, msg); } -template -inline void spdlog::logger::warn(const T &msg) -{ - log(level::warn, msg); +template +inline void spdlog::logger::warn(const T &msg) { + log(level::warn, msg); } -template -inline void spdlog::logger::error(const T &msg) -{ - log(level::err, msg); +template +inline void spdlog::logger::error(const T &msg) { + log(level::err, msg); } -template -inline void spdlog::logger::critical(const T &msg) -{ - log(level::critical, msg); +template +inline void spdlog::logger::critical(const T &msg) { + log(level::critical, msg); } #ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT -inline void wbuf_to_utf8buf(const fmt::wmemory_buffer &wbuf, fmt::memory_buffer &target) -{ - int wbuf_size = static_cast(wbuf.size()); - if (wbuf_size == 0) - { - return; - } +inline void wbuf_to_utf8buf(const fmt::wmemory_buffer &wbuf, + fmt::memory_buffer &target) { + int wbuf_size = static_cast(wbuf.size()); + if (wbuf_size == 0) { + return; + } - auto result_size = ::WideCharToMultiByte(CP_UTF8, 0, wbuf.data(), wbuf_size, NULL, 0, NULL, NULL); + auto result_size = ::WideCharToMultiByte(CP_UTF8, 0, wbuf.data(), wbuf_size, + NULL, 0, NULL, NULL); - if (result_size > 0) - { - target.resize(result_size); - ::WideCharToMultiByte(CP_UTF8, 0, wbuf.data(), wbuf_size, &target.data()[0], result_size, NULL, NULL); - } - else - { - throw spdlog::spdlog_ex(fmt::format("WideCharToMultiByte failed. Last error: {}", ::GetLastError())); - } + if (result_size > 0) { + target.resize(result_size); + ::WideCharToMultiByte(CP_UTF8, 0, wbuf.data(), wbuf_size, &target.data()[0], + result_size, NULL, NULL); + } else { + throw spdlog::spdlog_ex(fmt::format( + "WideCharToMultiByte failed. Last error: {}", ::GetLastError())); + } } -template -inline void spdlog::logger::log(source_loc source, level::level_enum lvl, const wchar_t *fmt, const Args &... args) -{ - if (!should_log(lvl)) - { - return; - } +template +inline void spdlog::logger::log(source_loc source, level::level_enum lvl, + const wchar_t *fmt, const Args &... args) { + if (!should_log(lvl)) { + return; + } - try - { - // format to wmemory_buffer and convert to utf8 - using details::fmt_helper::to_string_view; - fmt::wmemory_buffer wbuf; - fmt::format_to(wbuf, fmt, args...); - fmt::memory_buffer buf; - wbuf_to_utf8buf(wbuf, buf); - details::log_msg log_msg(source, &name_, lvl, to_string_view(buf)); - sink_it_(log_msg); - } - SPDLOG_CATCH_AND_HANDLE + try { + // format to wmemory_buffer and convert to utf8 + using details::fmt_helper::to_string_view; + fmt::wmemory_buffer wbuf; + fmt::format_to(wbuf, fmt, args...); + fmt::memory_buffer buf; + wbuf_to_utf8buf(wbuf, buf); + details::log_msg log_msg(source, &name_, lvl, to_string_view(buf)); + sink_it_(log_msg); + } + SPDLOG_CATCH_AND_HANDLE } -template -inline void spdlog::logger::log(level::level_enum lvl, const wchar_t *fmt, const Args &... args) -{ - log(source_loc{}, lvl, fmt, args...); +template +inline void spdlog::logger::log(level::level_enum lvl, const wchar_t *fmt, + const Args &... args) { + log(source_loc{}, lvl, fmt, args...); } -template -inline void spdlog::logger::trace(const wchar_t *fmt, const Args &... args) -{ - log(level::trace, fmt, args...); +template +inline void spdlog::logger::trace(const wchar_t *fmt, const Args &... args) { + log(level::trace, fmt, args...); } -template -inline void spdlog::logger::debug(const wchar_t *fmt, const Args &... args) -{ - log(level::debug, fmt, args...); +template +inline void spdlog::logger::debug(const wchar_t *fmt, const Args &... args) { + log(level::debug, fmt, args...); } -template -inline void spdlog::logger::info(const wchar_t *fmt, const Args &... args) -{ - log(level::info, fmt, args...); +template +inline void spdlog::logger::info(const wchar_t *fmt, const Args &... args) { + log(level::info, fmt, args...); } -template -inline void spdlog::logger::warn(const wchar_t *fmt, const Args &... args) -{ - log(level::warn, fmt, args...); +template +inline void spdlog::logger::warn(const wchar_t *fmt, const Args &... args) { + log(level::warn, fmt, args...); } -template -inline void spdlog::logger::error(const wchar_t *fmt, const Args &... args) -{ - log(level::err, fmt, args...); +template +inline void spdlog::logger::error(const wchar_t *fmt, const Args &... args) { + log(level::err, fmt, args...); } -template -inline void spdlog::logger::critical(const wchar_t *fmt, const Args &... args) -{ - log(level::critical, fmt, args...); +template +inline void spdlog::logger::critical(const wchar_t *fmt, const Args &... args) { + log(level::critical, fmt, args...); } -#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT +#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT // // name and level // -inline const std::string &spdlog::logger::name() const -{ - return name_; +inline const std::string &spdlog::logger::name() const { return name_; } + +inline void spdlog::logger::set_level(spdlog::level::level_enum log_level) { + level_.store(log_level); } -inline void spdlog::logger::set_level(spdlog::level::level_enum log_level) -{ - level_.store(log_level); +inline void spdlog::logger::set_error_handler( + spdlog::log_err_handler err_handler) { + err_handler_ = std::move(err_handler); } -inline void spdlog::logger::set_error_handler(spdlog::log_err_handler err_handler) -{ - err_handler_ = std::move(err_handler); +inline spdlog::log_err_handler spdlog::logger::error_handler() const { + return err_handler_; } -inline spdlog::log_err_handler spdlog::logger::error_handler() const -{ - return err_handler_; +inline void spdlog::logger::flush() { + try { + flush_(); + } + SPDLOG_CATCH_AND_HANDLE } -inline void spdlog::logger::flush() -{ - try - { - flush_(); - } - SPDLOG_CATCH_AND_HANDLE +inline void spdlog::logger::flush_on(level::level_enum log_level) { + flush_level_.store(log_level); } -inline void spdlog::logger::flush_on(level::level_enum log_level) -{ - flush_level_.store(log_level); +inline spdlog::level::level_enum spdlog::logger::flush_level() const { + return static_cast( + flush_level_.load(std::memory_order_relaxed)); } -inline spdlog::level::level_enum spdlog::logger::flush_level() const -{ - return static_cast(flush_level_.load(std::memory_order_relaxed)); +inline bool spdlog::logger::should_flush_(const details::log_msg &msg) { + auto flush_level = flush_level_.load(std::memory_order_relaxed); + return (msg.level >= flush_level) && (msg.level != level::off); } -inline bool spdlog::logger::should_flush_(const details::log_msg &msg) -{ - auto flush_level = flush_level_.load(std::memory_order_relaxed); - return (msg.level >= flush_level) && (msg.level != level::off); +inline spdlog::level::level_enum spdlog::logger::default_level() { + return static_cast(SPDLOG_ACTIVE_LEVEL); } -inline spdlog::level::level_enum spdlog::logger::default_level() -{ - return static_cast(SPDLOG_ACTIVE_LEVEL); +inline spdlog::level::level_enum spdlog::logger::level() const { + return static_cast( + level_.load(std::memory_order_relaxed)); } -inline spdlog::level::level_enum spdlog::logger::level() const -{ - return static_cast(level_.load(std::memory_order_relaxed)); -} - -inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) const -{ - return msg_level >= level_.load(std::memory_order_relaxed); +inline bool spdlog::logger::should_log( + spdlog::level::level_enum msg_level) const { + return msg_level >= level_.load(std::memory_order_relaxed); } // // protected virtual called at end of each user log call (if enabled) by the // line_logger // -inline void spdlog::logger::sink_it_(details::log_msg &msg) -{ +inline void spdlog::logger::sink_it_(details::log_msg &msg) { #if defined(SPDLOG_ENABLE_MESSAGE_COUNTER) - incr_msg_counter_(msg); + incr_msg_counter_(msg); #endif - for (auto &sink : sinks_) - { - if (sink->should_log(msg.level)) - { - sink->log(msg); - } + for (auto &sink : sinks_) { + if (sink->should_log(msg.level)) { + sink->log(msg); } + } - if (should_flush_(msg)) - { - flush_(); - } + if (should_flush_(msg)) { + flush_(); + } } -inline void spdlog::logger::flush_() -{ - for (auto &sink : sinks_) - { - sink->flush(); - } +inline void spdlog::logger::flush_() { + for (auto &sink : sinks_) { + sink->flush(); + } } -inline void spdlog::logger::default_err_handler_(const std::string &msg) -{ - auto now = time(nullptr); - if (now - last_err_time_ < 60) - { - return; - } - last_err_time_ = now; - auto tm_time = details::os::localtime(now); - char date_buf[100]; - std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time); - fmt::print(stderr, "[*** LOG ERROR ***] [{}] [{}] {}\n", date_buf, name(), msg); +inline void spdlog::logger::default_err_handler_(const std::string &msg) { + auto now = time(nullptr); + if (now - last_err_time_ < 60) { + return; + } + last_err_time_ = now; + auto tm_time = details::os::localtime(now); + char date_buf[100]; + std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time); + fmt::print(stderr, "[*** LOG ERROR ***] [{}] [{}] {}\n", date_buf, name(), + msg); } -inline void spdlog::logger::incr_msg_counter_(details::log_msg &msg) -{ - msg.msg_id = msg_counter_.fetch_add(1, std::memory_order_relaxed); +inline void spdlog::logger::incr_msg_counter_(details::log_msg &msg) { + msg.msg_id = msg_counter_.fetch_add(1, std::memory_order_relaxed); } -inline const std::vector &spdlog::logger::sinks() const -{ - return sinks_; +inline const std::vector &spdlog::logger::sinks() const { + return sinks_; } -inline std::vector &spdlog::logger::sinks() -{ - return sinks_; -} +inline std::vector &spdlog::logger::sinks() { return sinks_; } -inline std::shared_ptr spdlog::logger::clone(std::string logger_name) -{ - auto cloned = std::make_shared(std::move(logger_name), sinks_.begin(), sinks_.end()); - cloned->set_level(this->level()); - cloned->flush_on(this->flush_level()); - cloned->set_error_handler(this->error_handler()); - return cloned; +inline std::shared_ptr spdlog::logger::clone( + std::string logger_name) { + auto cloned = std::make_shared(std::move(logger_name), + sinks_.begin(), sinks_.end()); + cloned->set_level(this->level()); + cloned->flush_on(this->flush_level()); + cloned->set_error_handler(this->error_handler()); + return cloned; } diff --git a/src/cpp/include/deps/spdlog/details/mpmc_blocking_q.h b/src/cpp/include/deps/spdlog/details/mpmc_blocking_q.h old mode 100755 new mode 100644 index ca789fc66..7f35bdbac --- a/src/cpp/include/deps/spdlog/details/mpmc_blocking_q.h +++ b/src/cpp/include/deps/spdlog/details/mpmc_blocking_q.h @@ -12,110 +12,99 @@ // dequeue_for(..) - will block until the queue is not empty or timeout have // passed. -#include "spdlog/details/circular_q.h" - #include #include +#include "spdlog/details/circular_q.h" + namespace spdlog { namespace details { -template -class mpmc_blocking_queue -{ -public: - using item_type = T; - explicit mpmc_blocking_queue(size_t max_items) - : q_(max_items) - { - } +template +class mpmc_blocking_queue { + public: + using item_type = T; + explicit mpmc_blocking_queue(size_t max_items) : q_(max_items) {} #ifndef __MINGW32__ - // try to enqueue and block if no room left - void enqueue(T &&item) + // try to enqueue and block if no room left + void enqueue(T &&item) { { - { - std::unique_lock lock(queue_mutex_); - pop_cv_.wait(lock, [this] { return !this->q_.full(); }); - q_.push_back(std::move(item)); - } - push_cv_.notify_one(); + std::unique_lock lock(queue_mutex_); + pop_cv_.wait(lock, [this] { return !this->q_.full(); }); + q_.push_back(std::move(item)); } + push_cv_.notify_one(); + } - // enqueue immediately. overrun oldest message in the queue if no room left. - void enqueue_nowait(T &&item) + // enqueue immediately. overrun oldest message in the queue if no room left. + void enqueue_nowait(T &&item) { { - { - std::unique_lock lock(queue_mutex_); - q_.push_back(std::move(item)); - } - push_cv_.notify_one(); + std::unique_lock lock(queue_mutex_); + q_.push_back(std::move(item)); } + push_cv_.notify_one(); + } - // try to dequeue item. if no item found. wait upto timeout and try again - // Return true, if succeeded dequeue item, false otherwise - bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration) + // try to dequeue item. if no item found. wait upto timeout and try again + // Return true, if succeeded dequeue item, false otherwise + bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration) { { - { - std::unique_lock lock(queue_mutex_); - if (!push_cv_.wait_for(lock, wait_duration, [this] { return !this->q_.empty(); })) - { - return false; - } - q_.pop_front(popped_item); - } - pop_cv_.notify_one(); - return true; + std::unique_lock lock(queue_mutex_); + if (!push_cv_.wait_for(lock, wait_duration, + [this] { return !this->q_.empty(); })) { + return false; + } + q_.pop_front(popped_item); } + pop_cv_.notify_one(); + return true; + } #else - // apparently mingw deadlocks if the mutex is released before cv.notify_one(), - // so release the mutex at the very end each function. + // apparently mingw deadlocks if the mutex is released before cv.notify_one(), + // so release the mutex at the very end each function. - // try to enqueue and block if no room left - void enqueue(T &&item) - { - std::unique_lock lock(queue_mutex_); - pop_cv_.wait(lock, [this] { return !this->q_.full(); }); - q_.push_back(std::move(item)); - push_cv_.notify_one(); - } + // try to enqueue and block if no room left + void enqueue(T &&item) { + std::unique_lock lock(queue_mutex_); + pop_cv_.wait(lock, [this] { return !this->q_.full(); }); + q_.push_back(std::move(item)); + push_cv_.notify_one(); + } - // enqueue immediately. overrun oldest message in the queue if no room left. - void enqueue_nowait(T &&item) - { - std::unique_lock lock(queue_mutex_); - q_.push_back(std::move(item)); - push_cv_.notify_one(); - } + // enqueue immediately. overrun oldest message in the queue if no room left. + void enqueue_nowait(T &&item) { + std::unique_lock lock(queue_mutex_); + q_.push_back(std::move(item)); + push_cv_.notify_one(); + } - // try to dequeue item. if no item found. wait upto timeout and try again - // Return true, if succeeded dequeue item, false otherwise - bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration) - { - std::unique_lock lock(queue_mutex_); - if (!push_cv_.wait_for(lock, wait_duration, [this] { return !this->q_.empty(); })) - { - return false; - } - q_.pop_front(popped_item); - pop_cv_.notify_one(); - return true; + // try to dequeue item. if no item found. wait upto timeout and try again + // Return true, if succeeded dequeue item, false otherwise + bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration) { + std::unique_lock lock(queue_mutex_); + if (!push_cv_.wait_for(lock, wait_duration, + [this] { return !this->q_.empty(); })) { + return false; } + q_.pop_front(popped_item); + pop_cv_.notify_one(); + return true; + } #endif - size_t overrun_counter() - { - std::unique_lock lock(queue_mutex_); - return q_.overrun_counter(); - } + size_t overrun_counter() { + std::unique_lock lock(queue_mutex_); + return q_.overrun_counter(); + } -private: - std::mutex queue_mutex_; - std::condition_variable push_cv_; - std::condition_variable pop_cv_; - spdlog::details::circular_q q_; + private: + std::mutex queue_mutex_; + std::condition_variable push_cv_; + std::condition_variable pop_cv_; + spdlog::details::circular_q q_; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/null_mutex.h b/src/cpp/include/deps/spdlog/details/null_mutex.h old mode 100755 new mode 100644 index 3f495bd98..80f03a96e --- a/src/cpp/include/deps/spdlog/details/null_mutex.h +++ b/src/cpp/include/deps/spdlog/details/null_mutex.h @@ -10,36 +10,22 @@ namespace spdlog { namespace details { -struct null_mutex -{ - void lock() {} - void unlock() {} - bool try_lock() - { - return true; - } +struct null_mutex { + void lock() {} + void unlock() {} + bool try_lock() { return true; } }; -struct null_atomic_int -{ - int value; - null_atomic_int() = default; +struct null_atomic_int { + int value; + null_atomic_int() = default; - explicit null_atomic_int(int val) - : value(val) - { - } + explicit null_atomic_int(int val) : value(val) {} - int load(std::memory_order) const - { - return value; - } + int load(std::memory_order) const { return value; } - void store(int val) - { - value = val; - } + void store(int val) { value = val; } }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/os.h b/src/cpp/include/deps/spdlog/details/os.h old mode 100755 new mode 100644 index 646805e60..abc3dbffb --- a/src/cpp/include/deps/spdlog/details/os.h +++ b/src/cpp/include/deps/spdlog/details/os.h @@ -4,7 +4,8 @@ // #pragma once -#include "../common.h" +#include +#include #include #include @@ -14,98 +15,92 @@ #include #include #include -#include -#include #include +#include "../common.h" + #ifdef _WIN32 #ifndef NOMINMAX -#define NOMINMAX // prevent windows redefining min/max +#define NOMINMAX // prevent windows redefining min/max #endif #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#include // _get_osfhandle and _isatty support -#include // _get_pid support +#include // _get_osfhandle and _isatty support +#include // _get_pid support #include #ifdef __MINGW32__ #include #endif -#else // unix +#else // unix #include #include #ifdef __linux__ -#include //Use gettid() syscall under linux to get thread id +#include //Use gettid() syscall under linux to get thread id #elif __FreeBSD__ -#include //Use thr_self() syscall under FreeBSD to get thread id +#include //Use thr_self() syscall under FreeBSD to get thread id #endif -#endif // unix +#endif // unix -#ifndef __has_feature // Clang - feature checking macros. -#define __has_feature(x) 0 // Compatibility with non-clang compilers. +#ifndef __has_feature // Clang - feature checking macros. +#define __has_feature(x) 0 // Compatibility with non-clang compilers. #endif namespace spdlog { namespace details { namespace os { -inline spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT -{ - +inline spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT { #if defined __linux__ && defined SPDLOG_CLOCK_COARSE - timespec ts; - ::clock_gettime(CLOCK_REALTIME_COARSE, &ts); - return std::chrono::time_point( - std::chrono::duration_cast(std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec))); + timespec ts; + ::clock_gettime(CLOCK_REALTIME_COARSE, &ts); + return std::chrono::time_point( + std::chrono::duration_cast( + std::chrono::seconds(ts.tv_sec) + + std::chrono::nanoseconds(ts.tv_nsec))); #else - return log_clock::now(); + return log_clock::now(); #endif } -inline std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT -{ - +inline std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT { #ifdef _WIN32 - std::tm tm; - localtime_s(&tm, &time_tt); + std::tm tm; + localtime_s(&tm, &time_tt); #else - std::tm tm; - localtime_r(&time_tt, &tm); + std::tm tm; + localtime_r(&time_tt, &tm); #endif - return tm; + return tm; } -inline std::tm localtime() SPDLOG_NOEXCEPT -{ - std::time_t now_t = time(nullptr); - return localtime(now_t); +inline std::tm localtime() SPDLOG_NOEXCEPT { + std::time_t now_t = time(nullptr); + return localtime(now_t); } -inline std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT -{ - +inline std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT { #ifdef _WIN32 - std::tm tm; - gmtime_s(&tm, &time_tt); + std::tm tm; + gmtime_s(&tm, &time_tt); #else - std::tm tm; - gmtime_r(&time_tt, &tm); + std::tm tm; + gmtime_r(&time_tt, &tm); #endif - return tm; + return tm; } -inline std::tm gmtime() SPDLOG_NOEXCEPT -{ - std::time_t now_t = time(nullptr); - return gmtime(now_t); +inline std::tm gmtime() SPDLOG_NOEXCEPT { + std::time_t now_t = time(nullptr); + return gmtime(now_t); } // eol definition @@ -126,296 +121,274 @@ SPDLOG_CONSTEXPR static const char folder_sep = '\\'; SPDLOG_CONSTEXPR static const char folder_sep = '/'; #endif -inline void prevent_child_fd(FILE *f) -{ - +inline void prevent_child_fd(FILE *f) { #ifdef _WIN32 #if !defined(__cplusplus_winrt) - auto file_handle = (HANDLE)_get_osfhandle(_fileno(f)); - if (!::SetHandleInformation(file_handle, HANDLE_FLAG_INHERIT, 0)) - throw spdlog_ex("SetHandleInformation failed", errno); + auto file_handle = (HANDLE)_get_osfhandle(_fileno(f)); + if (!::SetHandleInformation(file_handle, HANDLE_FLAG_INHERIT, 0)) + throw spdlog_ex("SetHandleInformation failed", errno); #endif #else - auto fd = fileno(f); - if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) - { - throw spdlog_ex("fcntl with FD_CLOEXEC failed", errno); - } + auto fd = fileno(f); + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { + throw spdlog_ex("fcntl with FD_CLOEXEC failed", errno); + } #endif } // fopen_s on non windows for writing -inline bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode) -{ +inline bool fopen_s(FILE **fp, const filename_t &filename, + const filename_t &mode) { #ifdef _WIN32 #ifdef SPDLOG_WCHAR_FILENAMES - *fp = _wfsopen((filename.c_str()), mode.c_str(), _SH_DENYNO); + *fp = _wfsopen((filename.c_str()), mode.c_str(), _SH_DENYNO); #else - *fp = _fsopen((filename.c_str()), mode.c_str(), _SH_DENYNO); + *fp = _fsopen((filename.c_str()), mode.c_str(), _SH_DENYNO); #endif -#else // unix - *fp = fopen((filename.c_str()), mode.c_str()); +#else // unix + *fp = fopen((filename.c_str()), mode.c_str()); #endif #ifdef SPDLOG_PREVENT_CHILD_FD - if (*fp != nullptr) - { - prevent_child_fd(*fp); - } + if (*fp != nullptr) { + prevent_child_fd(*fp); + } #endif - return *fp == nullptr; + return *fp == nullptr; } -inline int remove(const filename_t &filename) SPDLOG_NOEXCEPT -{ +inline int remove(const filename_t &filename) SPDLOG_NOEXCEPT { #if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES) - return _wremove(filename.c_str()); + return _wremove(filename.c_str()); #else - return std::remove(filename.c_str()); + return std::remove(filename.c_str()); #endif } -inline int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT -{ +inline int rename(const filename_t &filename1, + const filename_t &filename2) SPDLOG_NOEXCEPT { #if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES) - return _wrename(filename1.c_str(), filename2.c_str()); + return _wrename(filename1.c_str(), filename2.c_str()); #else - return std::rename(filename1.c_str(), filename2.c_str()); + return std::rename(filename1.c_str(), filename2.c_str()); #endif } // Return if file exists -inline bool file_exists(const filename_t &filename) SPDLOG_NOEXCEPT -{ +inline bool file_exists(const filename_t &filename) SPDLOG_NOEXCEPT { #ifdef _WIN32 #ifdef SPDLOG_WCHAR_FILENAMES - auto attribs = GetFileAttributesW(filename.c_str()); + auto attribs = GetFileAttributesW(filename.c_str()); #else - auto attribs = GetFileAttributesA(filename.c_str()); + auto attribs = GetFileAttributesA(filename.c_str()); #endif - return (attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY)); -#else // common linux/unix all have the stat system call - struct stat buffer; - return (stat(filename.c_str(), &buffer) == 0); + return (attribs != INVALID_FILE_ATTRIBUTES && + !(attribs & FILE_ATTRIBUTE_DIRECTORY)); +#else // common linux/unix all have the stat system call + struct stat buffer; + return (stat(filename.c_str(), &buffer) == 0); #endif } // Return file size according to open FILE* object -inline size_t filesize(FILE *f) -{ - if (f == nullptr) - { - throw spdlog_ex("Failed getting file size. fd is null"); - } +inline size_t filesize(FILE *f) { + if (f == nullptr) { + throw spdlog_ex("Failed getting file size. fd is null"); + } #if defined(_WIN32) && !defined(__CYGWIN__) - int fd = _fileno(f); -#if _WIN64 // 64 bits - __int64 ret = _filelengthi64(fd); - if (ret >= 0) - { - return static_cast(ret); - } + int fd = _fileno(f); +#if _WIN64 // 64 bits + __int64 ret = _filelengthi64(fd); + if (ret >= 0) { + return static_cast(ret); + } -#else // windows 32 bits - long ret = _filelength(fd); - if (ret >= 0) - { - return static_cast(ret); - } +#else // windows 32 bits + long ret = _filelength(fd); + if (ret >= 0) { + return static_cast(ret); + } #endif -#else // unix - int fd = fileno(f); +#else // unix + int fd = fileno(f); // 64 bits(but not in osx or cygwin, where fstat64 is deprecated) -#if !defined(__FreeBSD__) && !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__)) && !defined(__CYGWIN__) - struct stat64 st; - if (fstat64(fd, &st) == 0) - { - return static_cast(st.st_size); - } -#else // unix 32 bits or cygwin - struct stat st; +#if !defined(__FreeBSD__) && !defined(__APPLE__) && \ + (defined(__x86_64__) || defined(__ppc64__)) && !defined(__CYGWIN__) + struct stat64 st; + if (fstat64(fd, &st) == 0) { + return static_cast(st.st_size); + } +#else // unix 32 bits or cygwin + struct stat st; - if (fstat(fd, &st) == 0) - { - return static_cast(st.st_size); - } + if (fstat(fd, &st) == 0) { + return static_cast(st.st_size); + } #endif #endif - throw spdlog_ex("Failed getting file size from fd", errno); + throw spdlog_ex("Failed getting file size from fd", errno); } // Return utc offset in minutes or throw spdlog_ex on failure -inline int utc_minutes_offset(const std::tm &tm = details::os::localtime()) -{ - +inline int utc_minutes_offset(const std::tm &tm = details::os::localtime()) { #ifdef _WIN32 #if _WIN32_WINNT < _WIN32_WINNT_WS08 - TIME_ZONE_INFORMATION tzinfo; - auto rv = GetTimeZoneInformation(&tzinfo); + TIME_ZONE_INFORMATION tzinfo; + auto rv = GetTimeZoneInformation(&tzinfo); #else - DYNAMIC_TIME_ZONE_INFORMATION tzinfo; - auto rv = GetDynamicTimeZoneInformation(&tzinfo); + DYNAMIC_TIME_ZONE_INFORMATION tzinfo; + auto rv = GetDynamicTimeZoneInformation(&tzinfo); #endif - if (rv == TIME_ZONE_ID_INVALID) - throw spdlog::spdlog_ex("Failed getting timezone info. ", errno); + if (rv == TIME_ZONE_ID_INVALID) + throw spdlog::spdlog_ex("Failed getting timezone info. ", errno); - int offset = -tzinfo.Bias; - if (tm.tm_isdst) - { - offset -= tzinfo.DaylightBias; - } - else - { - offset -= tzinfo.StandardBias; - } - return offset; + int offset = -tzinfo.Bias; + if (tm.tm_isdst) { + offset -= tzinfo.DaylightBias; + } else { + offset -= tzinfo.StandardBias; + } + return offset; #else #if defined(sun) || defined(__sun) || defined(_AIX) - // 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris - struct helper - { - static long int calculate_gmt_offset(const std::tm &localtm = details::os::localtime(), const std::tm &gmtm = details::os::gmtime()) - { - int local_year = localtm.tm_year + (1900 - 1); - int gmt_year = gmtm.tm_year + (1900 - 1); + // 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris + struct helper { + static long int calculate_gmt_offset( + const std::tm &localtm = details::os::localtime(), + const std::tm &gmtm = details::os::gmtime()) { + int local_year = localtm.tm_year + (1900 - 1); + int gmt_year = gmtm.tm_year + (1900 - 1); - long int days = ( - // difference in day of year - localtm.tm_yday - - gmtm.tm_yday + long int days = ( + // difference in day of year + localtm.tm_yday - + gmtm.tm_yday - // + intervening leap days - + ((local_year >> 2) - (gmt_year >> 2)) - (local_year / 100 - gmt_year / 100) + - ((local_year / 100 >> 2) - (gmt_year / 100 >> 2)) + // + intervening leap days + + ((local_year >> 2) - (gmt_year >> 2)) - + (local_year / 100 - gmt_year / 100) + + ((local_year / 100 >> 2) - (gmt_year / 100 >> 2)) - // + difference in years * 365 */ - + (long int)(local_year - gmt_year) * 365); + // + difference in years * 365 */ + + (long int)(local_year - gmt_year) * 365); - long int hours = (24 * days) + (localtm.tm_hour - gmtm.tm_hour); - long int mins = (60 * hours) + (localtm.tm_min - gmtm.tm_min); - long int secs = (60 * mins) + (localtm.tm_sec - gmtm.tm_sec); + long int hours = (24 * days) + (localtm.tm_hour - gmtm.tm_hour); + long int mins = (60 * hours) + (localtm.tm_min - gmtm.tm_min); + long int secs = (60 * mins) + (localtm.tm_sec - gmtm.tm_sec); - return secs; - } - }; + return secs; + } + }; - auto offset_seconds = helper::calculate_gmt_offset(tm); + auto offset_seconds = helper::calculate_gmt_offset(tm); #else - auto offset_seconds = tm.tm_gmtoff; + auto offset_seconds = tm.tm_gmtoff; #endif - return static_cast(offset_seconds / 60); + return static_cast(offset_seconds / 60); #endif } // Return current thread id as size_t // It exists because the std::this_thread::get_id() is much slower(especially // under VS 2013) -inline size_t _thread_id() SPDLOG_NOEXCEPT -{ +inline size_t _thread_id() SPDLOG_NOEXCEPT { #ifdef _WIN32 - return static_cast(::GetCurrentThreadId()); + return static_cast(::GetCurrentThreadId()); #elif __linux__ #if defined(__ANDROID__) && defined(__ANDROID_API__) && (__ANDROID_API__ < 21) #define SYS_gettid __NR_gettid #endif - return static_cast(syscall(SYS_gettid)); + return static_cast(syscall(SYS_gettid)); #elif __FreeBSD__ - long tid; - thr_self(&tid); - return static_cast(tid); + long tid; + thr_self(&tid); + return static_cast(tid); #elif __APPLE__ - uint64_t tid; - pthread_threadid_np(nullptr, &tid); - return static_cast(tid); -#else // Default to standard C++11 (other Unix) - return static_cast(std::hash()(std::this_thread::get_id())); + uint64_t tid; + pthread_threadid_np(nullptr, &tid); + return static_cast(tid); +#else // Default to standard C++11 (other Unix) + return static_cast( + std::hash()(std::this_thread::get_id())); #endif } // Return current thread id as size_t (from thread local storage) -inline size_t thread_id() SPDLOG_NOEXCEPT -{ +inline size_t thread_id() SPDLOG_NOEXCEPT { #if defined(SPDLOG_NO_TLS) - return _thread_id(); -#else // cache thread id in tls - static thread_local const size_t tid = _thread_id(); - return tid; + return _thread_id(); +#else // cache thread id in tls + static thread_local const size_t tid = _thread_id(); + return tid; #endif } // This is avoid msvc issue in sleep_for that happens if the clock changes. // See https://github.com/gabime/spdlog/issues/609 -inline void sleep_for_millis(int milliseconds) SPDLOG_NOEXCEPT -{ +inline void sleep_for_millis(int milliseconds) SPDLOG_NOEXCEPT { #if defined(_WIN32) - ::Sleep(milliseconds); + ::Sleep(milliseconds); #else - std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); + std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); #endif } // wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined) #if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES) #define SPDLOG_FILENAME_T(s) L##s -inline std::string filename_to_str(const filename_t &filename) -{ - std::wstring_convert, wchar_t> c; - return c.to_bytes(filename); +inline std::string filename_to_str(const filename_t &filename) { + std::wstring_convert, wchar_t> c; + return c.to_bytes(filename); } #else #define SPDLOG_FILENAME_T(s) s -inline std::string filename_to_str(const filename_t &filename) -{ - return filename; +inline std::string filename_to_str(const filename_t &filename) { + return filename; } #endif -inline int pid() -{ - +inline int pid() { #ifdef _WIN32 - return static_cast(::GetCurrentProcessId()); + return static_cast(::GetCurrentProcessId()); #else - return static_cast(::getpid()); + return static_cast(::getpid()); #endif } // Determine if the terminal supports colors // Source: https://github.com/agauniyal/rang/ -inline bool is_color_terminal() SPDLOG_NOEXCEPT -{ +inline bool is_color_terminal() SPDLOG_NOEXCEPT { #ifdef _WIN32 - return true; + return true; #else - static constexpr const char *Terms[] = { - "ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm", "linux", "msys", "putty", "rxvt", "screen", "vt100", "xterm"}; + static constexpr const char *Terms[] = { + "ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm", + "linux", "msys", "putty", "rxvt", "screen", "vt100", "xterm"}; - const char *env_p = std::getenv("TERM"); - if (env_p == nullptr) - { - return false; - } + const char *env_p = std::getenv("TERM"); + if (env_p == nullptr) { + return false; + } - static const bool result = - std::any_of(std::begin(Terms), std::end(Terms), [&](const char *term) { return std::strstr(env_p, term) != nullptr; }); - return result; + static const bool result = std::any_of( + std::begin(Terms), std::end(Terms), + [&](const char *term) { return std::strstr(env_p, term) != nullptr; }); + return result; #endif } // Detrmine if the terminal attached // Source: https://github.com/agauniyal/rang/ -inline bool in_terminal(FILE *file) SPDLOG_NOEXCEPT -{ - +inline bool in_terminal(FILE *file) SPDLOG_NOEXCEPT { #ifdef _WIN32 - return _isatty(_fileno(file)) != 0; + return _isatty(_fileno(file)) != 0; #else - return isatty(fileno(file)) != 0; + return isatty(fileno(file)) != 0; #endif } -} // namespace os -} // namespace details -} // namespace spdlog +} // namespace os +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/pattern_formatter.h b/src/cpp/include/deps/spdlog/details/pattern_formatter.h old mode 100755 new mode 100644 index c0ad86e8e..29483babc --- a/src/cpp/include/deps/spdlog/details/pattern_formatter.h +++ b/src/cpp/include/deps/spdlog/details/pattern_formatter.h @@ -5,16 +5,10 @@ #pragma once -#include "spdlog/details/fmt_helper.h" -#include "spdlog/details/log_msg.h" -#include "spdlog/details/os.h" -#include "spdlog/fmt/fmt.h" -#include "spdlog/formatter.h" - #include +#include #include #include -#include #include #include #include @@ -22,1315 +16,1173 @@ #include #include +#include "spdlog/details/fmt_helper.h" +#include "spdlog/details/log_msg.h" +#include "spdlog/details/os.h" +#include "spdlog/fmt/fmt.h" +#include "spdlog/formatter.h" + namespace spdlog { namespace details { // padding information. -struct padding_info -{ - enum pad_side - { - left, - right, - center - }; +struct padding_info { + enum pad_side { left, right, center }; - padding_info() = default; - padding_info(size_t width, padding_info::pad_side side) - : width_(width) - , side_(side) - { - } + padding_info() = default; + padding_info(size_t width, padding_info::pad_side side) + : width_(width), side_(side) {} - bool enabled() const - { - return width_ != 0; - } - const size_t width_ = 0; - const pad_side side_ = left; + bool enabled() const { return width_ != 0; } + const size_t width_ = 0; + const pad_side side_ = left; }; -class scoped_pad -{ -public: - scoped_pad(size_t wrapped_size, padding_info &padinfo, fmt::memory_buffer &dest) - : padinfo_(padinfo) - , dest_(dest) - { - - if (padinfo_.width_ <= wrapped_size) - { - total_pad_ = 0; - return; - } - - total_pad_ = padinfo.width_ - wrapped_size; - if (padinfo_.side_ == padding_info::left) - { - pad_it(total_pad_); - total_pad_ = 0; - } - else if (padinfo_.side_ == padding_info::center) - { - auto half_pad = total_pad_ / 2; - auto reminder = total_pad_ & 1; - pad_it(half_pad); - total_pad_ = half_pad + reminder; // for the right side - } +class scoped_pad { + public: + scoped_pad(size_t wrapped_size, padding_info &padinfo, + fmt::memory_buffer &dest) + : padinfo_(padinfo), dest_(dest) { + if (padinfo_.width_ <= wrapped_size) { + total_pad_ = 0; + return; } - scoped_pad(spdlog::string_view_t txt, padding_info &padinfo, fmt::memory_buffer &dest) - : scoped_pad(txt.size(), padinfo, dest) - { + total_pad_ = padinfo.width_ - wrapped_size; + if (padinfo_.side_ == padding_info::left) { + pad_it(total_pad_); + total_pad_ = 0; + } else if (padinfo_.side_ == padding_info::center) { + auto half_pad = total_pad_ / 2; + auto reminder = total_pad_ & 1; + pad_it(half_pad); + total_pad_ = half_pad + reminder; // for the right side } + } - ~scoped_pad() - { - if (total_pad_) - { - pad_it(total_pad_); - } + scoped_pad(spdlog::string_view_t txt, padding_info &padinfo, + fmt::memory_buffer &dest) + : scoped_pad(txt.size(), padinfo, dest) {} + + ~scoped_pad() { + if (total_pad_) { + pad_it(total_pad_); } + } -private: - void pad_it(size_t count) - { - // count = std::min(count, spaces_.size()); - assert(count <= spaces_.size()); - fmt_helper::append_string_view(string_view_t(spaces_.data(), count), dest_); - } + private: + void pad_it(size_t count) { + // count = std::min(count, spaces_.size()); + assert(count <= spaces_.size()); + fmt_helper::append_string_view(string_view_t(spaces_.data(), count), dest_); + } - const padding_info &padinfo_; - fmt::memory_buffer &dest_; - size_t total_pad_; - string_view_t spaces_{" " - " ", - 128}; + const padding_info &padinfo_; + fmt::memory_buffer &dest_; + size_t total_pad_; + string_view_t spaces_{ + " " + " ", + 128}; }; -class flag_formatter -{ -public: - explicit flag_formatter(padding_info padinfo) - : padinfo_(padinfo) - { - } - flag_formatter() = default; - virtual ~flag_formatter() = default; - virtual void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) = 0; +class flag_formatter { + public: + explicit flag_formatter(padding_info padinfo) : padinfo_(padinfo) {} + flag_formatter() = default; + virtual ~flag_formatter() = default; + virtual void format(const details::log_msg &msg, const std::tm &tm_time, + fmt::memory_buffer &dest) = 0; -protected: - padding_info padinfo_; + protected: + padding_info padinfo_; }; /////////////////////////////////////////////////////////////////////// // name & level pattern appender /////////////////////////////////////////////////////////////////////// -class name_formatter : public flag_formatter -{ -public: - explicit name_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class name_formatter : public flag_formatter { + public: + explicit name_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - if (padinfo_.enabled()) - { - scoped_pad p(*msg.logger_name, padinfo_, dest); - fmt_helper::append_string_view(*msg.logger_name, dest); - } - else - { - fmt_helper::append_string_view(*msg.logger_name, dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + if (padinfo_.enabled()) { + scoped_pad p(*msg.logger_name, padinfo_, dest); + fmt_helper::append_string_view(*msg.logger_name, dest); + } else { + fmt_helper::append_string_view(*msg.logger_name, dest); } + } }; // log level appender -class level_formatter : public flag_formatter -{ -public: - explicit level_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class level_formatter : public flag_formatter { + public: + explicit level_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - string_view_t &level_name = level::to_string_view(msg.level); - if (padinfo_.enabled()) - { - scoped_pad p(level_name, padinfo_, dest); - fmt_helper::append_string_view(level_name, dest); - } - else - { - fmt_helper::append_string_view(level_name, dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + string_view_t &level_name = level::to_string_view(msg.level); + if (padinfo_.enabled()) { + scoped_pad p(level_name, padinfo_, dest); + fmt_helper::append_string_view(level_name, dest); + } else { + fmt_helper::append_string_view(level_name, dest); } + } }; // short log level appender -class short_level_formatter : public flag_formatter -{ -public: - explicit short_level_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class short_level_formatter : public flag_formatter { + public: + explicit short_level_formatter(padding_info padinfo) + : flag_formatter(padinfo) {} - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - string_view_t level_name{level::to_short_c_str(msg.level)}; - scoped_pad p(level_name, padinfo_, dest); - fmt_helper::append_string_view(level_name, dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + string_view_t level_name{level::to_short_c_str(msg.level)}; + scoped_pad p(level_name, padinfo_, dest); + fmt_helper::append_string_view(level_name, dest); + } }; /////////////////////////////////////////////////////////////////////// // Date time pattern appenders /////////////////////////////////////////////////////////////////////// -static const char *ampm(const tm &t) -{ - return t.tm_hour >= 12 ? "PM" : "AM"; -} +static const char *ampm(const tm &t) { return t.tm_hour >= 12 ? "PM" : "AM"; } -static int to12h(const tm &t) -{ - return t.tm_hour > 12 ? t.tm_hour - 12 : t.tm_hour; +static int to12h(const tm &t) { + return t.tm_hour > 12 ? t.tm_hour - 12 : t.tm_hour; } // Abbreviated weekday name static const char *days[]{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; -class a_formatter : public flag_formatter -{ -public: - explicit a_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class a_formatter : public flag_formatter { + public: + explicit a_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - string_view_t field_value{days[tm_time.tm_wday]}; - scoped_pad p(field_value, padinfo_, dest); - fmt_helper::append_string_view(field_value, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + string_view_t field_value{days[tm_time.tm_wday]}; + scoped_pad p(field_value, padinfo_, dest); + fmt_helper::append_string_view(field_value, dest); + } }; // Full weekday name -static const char *full_days[]{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; -class A_formatter : public flag_formatter -{ -public: - explicit A_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +static const char *full_days[]{"Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday"}; +class A_formatter : public flag_formatter { + public: + explicit A_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - string_view_t field_value{full_days[tm_time.tm_wday]}; - scoped_pad p(field_value, padinfo_, dest); - fmt_helper::append_string_view(field_value, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + string_view_t field_value{full_days[tm_time.tm_wday]}; + scoped_pad p(field_value, padinfo_, dest); + fmt_helper::append_string_view(field_value, dest); + } }; // Abbreviated month -static const char *months[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"}; -class b_formatter : public flag_formatter -{ -public: - explicit b_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +static const char *months[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"}; +class b_formatter : public flag_formatter { + public: + explicit b_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - string_view_t field_value{months[tm_time.tm_mon]}; - scoped_pad p(field_value, padinfo_, dest); - fmt_helper::append_string_view(field_value, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + string_view_t field_value{months[tm_time.tm_mon]}; + scoped_pad p(field_value, padinfo_, dest); + fmt_helper::append_string_view(field_value, dest); + } }; // Full month name static const char *full_months[]{ - "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; -class B_formatter : public flag_formatter -{ -public: - explicit B_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December"}; +class B_formatter : public flag_formatter { + public: + explicit B_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - string_view_t field_value{full_months[tm_time.tm_mon]}; - scoped_pad p(field_value, padinfo_, dest); - fmt_helper::append_string_view(field_value, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + string_view_t field_value{full_months[tm_time.tm_mon]}; + scoped_pad p(field_value, padinfo_, dest); + fmt_helper::append_string_view(field_value, dest); + } }; // Date and time representation (Thu Aug 23 15:35:46 2014) -class c_formatter final : public flag_formatter -{ -public: - explicit c_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class c_formatter final : public flag_formatter { + public: + explicit c_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 24; - scoped_pad p(field_size, padinfo_, dest); + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 24; + scoped_pad p(field_size, padinfo_, dest); - fmt_helper::append_string_view(days[tm_time.tm_wday], dest); - dest.push_back(' '); - fmt_helper::append_string_view(months[tm_time.tm_mon], dest); - dest.push_back(' '); - fmt_helper::append_int(tm_time.tm_mday, dest); - dest.push_back(' '); - // time + fmt_helper::append_string_view(days[tm_time.tm_wday], dest); + dest.push_back(' '); + fmt_helper::append_string_view(months[tm_time.tm_mon], dest); + dest.push_back(' '); + fmt_helper::append_int(tm_time.tm_mday, dest); + dest.push_back(' '); + // time - fmt_helper::pad2(tm_time.tm_hour, dest); - dest.push_back(':'); - fmt_helper::pad2(tm_time.tm_min, dest); - dest.push_back(':'); - fmt_helper::pad2(tm_time.tm_sec, dest); - dest.push_back(' '); - fmt_helper::append_int(tm_time.tm_year + 1900, dest); - } + fmt_helper::pad2(tm_time.tm_hour, dest); + dest.push_back(':'); + fmt_helper::pad2(tm_time.tm_min, dest); + dest.push_back(':'); + fmt_helper::pad2(tm_time.tm_sec, dest); + dest.push_back(' '); + fmt_helper::append_int(tm_time.tm_year + 1900, dest); + } }; // year - 2 digit -class C_formatter final : public flag_formatter -{ -public: - explicit C_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class C_formatter final : public flag_formatter { + public: + explicit C_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 2; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(tm_time.tm_year % 100, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 2; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad2(tm_time.tm_year % 100, dest); + } }; // Short MM/DD/YY date, equivalent to %m/%d/%y 08/23/01 -class D_formatter final : public flag_formatter -{ -public: - explicit D_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class D_formatter final : public flag_formatter { + public: + explicit D_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 10; - scoped_pad p(field_size, padinfo_, dest); + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 10; + scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(tm_time.tm_mon + 1, dest); - dest.push_back('/'); - fmt_helper::pad2(tm_time.tm_mday, dest); - dest.push_back('/'); - fmt_helper::pad2(tm_time.tm_year % 100, dest); - } + fmt_helper::pad2(tm_time.tm_mon + 1, dest); + dest.push_back('/'); + fmt_helper::pad2(tm_time.tm_mday, dest); + dest.push_back('/'); + fmt_helper::pad2(tm_time.tm_year % 100, dest); + } }; // year - 4 digit -class Y_formatter final : public flag_formatter -{ -public: - explicit Y_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class Y_formatter final : public flag_formatter { + public: + explicit Y_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 4; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::append_int(tm_time.tm_year + 1900, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 4; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::append_int(tm_time.tm_year + 1900, dest); + } }; // month 1-12 -class m_formatter final : public flag_formatter -{ -public: - explicit m_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class m_formatter final : public flag_formatter { + public: + explicit m_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 2; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(tm_time.tm_mon + 1, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 2; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad2(tm_time.tm_mon + 1, dest); + } }; // day of month 1-31 -class d_formatter final : public flag_formatter -{ -public: - explicit d_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class d_formatter final : public flag_formatter { + public: + explicit d_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 2; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(tm_time.tm_mday, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 2; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad2(tm_time.tm_mday, dest); + } }; // hours in 24 format 0-23 -class H_formatter final : public flag_formatter -{ -public: - explicit H_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class H_formatter final : public flag_formatter { + public: + explicit H_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 2; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(tm_time.tm_hour, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 2; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad2(tm_time.tm_hour, dest); + } }; // hours in 12 format 1-12 -class I_formatter final : public flag_formatter -{ -public: - explicit I_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class I_formatter final : public flag_formatter { + public: + explicit I_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 2; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(to12h(tm_time), dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 2; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad2(to12h(tm_time), dest); + } }; // minutes 0-59 -class M_formatter final : public flag_formatter -{ -public: - explicit M_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class M_formatter final : public flag_formatter { + public: + explicit M_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 2; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(tm_time.tm_min, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 2; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad2(tm_time.tm_min, dest); + } }; // seconds 0-59 -class S_formatter final : public flag_formatter -{ -public: - explicit S_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class S_formatter final : public flag_formatter { + public: + explicit S_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 2; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(tm_time.tm_sec, dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 2; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad2(tm_time.tm_sec, dest); + } }; // milliseconds -class e_formatter final : public flag_formatter -{ -public: - explicit e_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class e_formatter final : public flag_formatter { + public: + explicit e_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - auto millis = fmt_helper::time_fraction(msg.time); - if (padinfo_.enabled()) - { - const size_t field_size = 3; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad3(static_cast(millis.count()), dest); - } - else - { - fmt_helper::pad3(static_cast(millis.count()), dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + auto millis = + fmt_helper::time_fraction(msg.time); + if (padinfo_.enabled()) { + const size_t field_size = 3; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad3(static_cast(millis.count()), dest); + } else { + fmt_helper::pad3(static_cast(millis.count()), dest); } + } }; // microseconds -class f_formatter final : public flag_formatter -{ -public: - explicit f_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class f_formatter final : public flag_formatter { + public: + explicit f_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - auto micros = fmt_helper::time_fraction(msg.time); - if (padinfo_.enabled()) - { - const size_t field_size = 6; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad6(static_cast(micros.count()), dest); - } - else - { - fmt_helper::pad6(static_cast(micros.count()), dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + auto micros = + fmt_helper::time_fraction(msg.time); + if (padinfo_.enabled()) { + const size_t field_size = 6; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad6(static_cast(micros.count()), dest); + } else { + fmt_helper::pad6(static_cast(micros.count()), dest); } + } }; // nanoseconds -class F_formatter final : public flag_formatter -{ -public: - explicit F_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class F_formatter final : public flag_formatter { + public: + explicit F_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - auto ns = fmt_helper::time_fraction(msg.time); - if (padinfo_.enabled()) - { - const size_t field_size = 9; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad9(static_cast(ns.count()), dest); - } - else - { - fmt_helper::pad9(static_cast(ns.count()), dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + auto ns = fmt_helper::time_fraction(msg.time); + if (padinfo_.enabled()) { + const size_t field_size = 9; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad9(static_cast(ns.count()), dest); + } else { + fmt_helper::pad9(static_cast(ns.count()), dest); } + } }; // seconds since epoch -class E_formatter final : public flag_formatter -{ -public: - explicit E_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class E_formatter final : public flag_formatter { + public: + explicit E_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - const size_t field_size = 10; - scoped_pad p(field_size, padinfo_, dest); - auto duration = msg.time.time_since_epoch(); - auto seconds = std::chrono::duration_cast(duration).count(); - fmt_helper::append_int(seconds, dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + const size_t field_size = 10; + scoped_pad p(field_size, padinfo_, dest); + auto duration = msg.time.time_since_epoch(); + auto seconds = + std::chrono::duration_cast(duration).count(); + fmt_helper::append_int(seconds, dest); + } }; // AM/PM -class p_formatter final : public flag_formatter -{ -public: - explicit p_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class p_formatter final : public flag_formatter { + public: + explicit p_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 2; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::append_string_view(ampm(tm_time), dest); - } + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 2; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::append_string_view(ampm(tm_time), dest); + } }; // 12 hour clock 02:55:02 pm -class r_formatter final : public flag_formatter -{ -public: - explicit r_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class r_formatter final : public flag_formatter { + public: + explicit r_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 11; - scoped_pad p(field_size, padinfo_, dest); + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 11; + scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(to12h(tm_time), dest); - dest.push_back(':'); - fmt_helper::pad2(tm_time.tm_min, dest); - dest.push_back(':'); - fmt_helper::pad2(tm_time.tm_sec, dest); - dest.push_back(' '); - fmt_helper::append_string_view(ampm(tm_time), dest); - } + fmt_helper::pad2(to12h(tm_time), dest); + dest.push_back(':'); + fmt_helper::pad2(tm_time.tm_min, dest); + dest.push_back(':'); + fmt_helper::pad2(tm_time.tm_sec, dest); + dest.push_back(' '); + fmt_helper::append_string_view(ampm(tm_time), dest); + } }; // 24-hour HH:MM time, equivalent to %H:%M -class R_formatter final : public flag_formatter -{ -public: - explicit R_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class R_formatter final : public flag_formatter { + public: + explicit R_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 5; - scoped_pad p(field_size, padinfo_, dest); + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 5; + scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(tm_time.tm_hour, dest); - dest.push_back(':'); - fmt_helper::pad2(tm_time.tm_min, dest); - } + fmt_helper::pad2(tm_time.tm_hour, dest); + dest.push_back(':'); + fmt_helper::pad2(tm_time.tm_min, dest); + } }; // ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S -class T_formatter final : public flag_formatter -{ -public: - explicit T_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class T_formatter final : public flag_formatter { + public: + explicit T_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 8; - scoped_pad p(field_size, padinfo_, dest); + void format(const details::log_msg &, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 8; + scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad2(tm_time.tm_hour, dest); - dest.push_back(':'); - fmt_helper::pad2(tm_time.tm_min, dest); - dest.push_back(':'); - fmt_helper::pad2(tm_time.tm_sec, dest); - } + fmt_helper::pad2(tm_time.tm_hour, dest); + dest.push_back(':'); + fmt_helper::pad2(tm_time.tm_min, dest); + dest.push_back(':'); + fmt_helper::pad2(tm_time.tm_sec, dest); + } }; // ISO 8601 offset from UTC in timezone (+-HH:MM) -class z_formatter final : public flag_formatter -{ -public: - explicit z_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class z_formatter final : public flag_formatter { + public: + explicit z_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - const std::chrono::seconds cache_refresh = std::chrono::seconds(5); + const std::chrono::seconds cache_refresh = std::chrono::seconds(5); - z_formatter() = default; - z_formatter(const z_formatter &) = delete; - z_formatter &operator=(const z_formatter &) = delete; + z_formatter() = default; + z_formatter(const z_formatter &) = delete; + z_formatter &operator=(const z_formatter &) = delete; - void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - const size_t field_size = 6; - scoped_pad p(field_size, padinfo_, dest); + void format(const details::log_msg &msg, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + const size_t field_size = 6; + scoped_pad p(field_size, padinfo_, dest); #ifdef _WIN32 - int total_minutes = get_cached_offset(msg, tm_time); + int total_minutes = get_cached_offset(msg, tm_time); #else - // No need to chache under gcc, - // it is very fast (already stored in tm.tm_gmtoff) - (void)(msg); - int total_minutes = os::utc_minutes_offset(tm_time); + // No need to chache under gcc, + // it is very fast (already stored in tm.tm_gmtoff) + (void)(msg); + int total_minutes = os::utc_minutes_offset(tm_time); #endif - bool is_negative = total_minutes < 0; - if (is_negative) - { - total_minutes = -total_minutes; - dest.push_back('-'); - } - else - { - dest.push_back('+'); - } - - fmt_helper::pad2(total_minutes / 60, dest); // hours - dest.push_back(':'); - fmt_helper::pad2(total_minutes % 60, dest); // minutes + bool is_negative = total_minutes < 0; + if (is_negative) { + total_minutes = -total_minutes; + dest.push_back('-'); + } else { + dest.push_back('+'); } -private: - log_clock::time_point last_update_{std::chrono::seconds(0)}; + fmt_helper::pad2(total_minutes / 60, dest); // hours + dest.push_back(':'); + fmt_helper::pad2(total_minutes % 60, dest); // minutes + } + + private: + log_clock::time_point last_update_{std::chrono::seconds(0)}; #ifdef _WIN32 - int offset_minutes_{0}; + int offset_minutes_{0}; - int get_cached_offset(const log_msg &msg, const std::tm &tm_time) - { - if (msg.time - last_update_ >= cache_refresh) - { - offset_minutes_ = os::utc_minutes_offset(tm_time); - last_update_ = msg.time; - } - return offset_minutes_; + int get_cached_offset(const log_msg &msg, const std::tm &tm_time) { + if (msg.time - last_update_ >= cache_refresh) { + offset_minutes_ = os::utc_minutes_offset(tm_time); + last_update_ = msg.time; } + return offset_minutes_; + } #endif }; // Thread id -class t_formatter final : public flag_formatter -{ -public: - explicit t_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class t_formatter final : public flag_formatter { + public: + explicit t_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - if (padinfo_.enabled()) - { - const auto field_size = fmt_helper::count_digits(msg.thread_id); - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::append_int(msg.thread_id, dest); - } - else - { - fmt_helper::append_int(msg.thread_id, dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + if (padinfo_.enabled()) { + const auto field_size = fmt_helper::count_digits(msg.thread_id); + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::append_int(msg.thread_id, dest); + } else { + fmt_helper::append_int(msg.thread_id, dest); } + } }; // Current pid -class pid_formatter final : public flag_formatter -{ -public: - explicit pid_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class pid_formatter final : public flag_formatter { + public: + explicit pid_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &, const std::tm &, fmt::memory_buffer &dest) override - { - const auto pid = static_cast(details::os::pid()); - if (padinfo_.enabled()) - { - auto field_size = fmt_helper::count_digits(pid); - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::append_int(pid, dest); - } - else - { - fmt_helper::append_int(pid, dest); - } + void format(const details::log_msg &, const std::tm &, + fmt::memory_buffer &dest) override { + const auto pid = static_cast(details::os::pid()); + if (padinfo_.enabled()) { + auto field_size = fmt_helper::count_digits(pid); + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::append_int(pid, dest); + } else { + fmt_helper::append_int(pid, dest); } + } }; // message counter formatter -class i_formatter final : public flag_formatter -{ -public: - explicit i_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class i_formatter final : public flag_formatter { + public: + explicit i_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - const size_t field_size = 6; - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::pad6(msg.msg_id, dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + const size_t field_size = 6; + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::pad6(msg.msg_id, dest); + } }; -class v_formatter final : public flag_formatter -{ -public: - explicit v_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class v_formatter final : public flag_formatter { + public: + explicit v_formatter(padding_info padinfo) : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - if (padinfo_.enabled()) - { - scoped_pad p(msg.payload, padinfo_, dest); - fmt_helper::append_string_view(msg.payload, dest); - } - else - { - fmt_helper::append_string_view(msg.payload, dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + if (padinfo_.enabled()) { + scoped_pad p(msg.payload, padinfo_, dest); + fmt_helper::append_string_view(msg.payload, dest); + } else { + fmt_helper::append_string_view(msg.payload, dest); } + } }; -class ch_formatter final : public flag_formatter -{ -public: - explicit ch_formatter(char ch) - : ch_(ch) - { - } +class ch_formatter final : public flag_formatter { + public: + explicit ch_formatter(char ch) : ch_(ch) {} - void format(const details::log_msg &, const std::tm &, fmt::memory_buffer &dest) override - { - const size_t field_size = 1; - scoped_pad p(field_size, padinfo_, dest); - dest.push_back(ch_); - } + void format(const details::log_msg &, const std::tm &, + fmt::memory_buffer &dest) override { + const size_t field_size = 1; + scoped_pad p(field_size, padinfo_, dest); + dest.push_back(ch_); + } -private: - char ch_; + private: + char ch_; }; // aggregate user chars to display as is -class aggregate_formatter final : public flag_formatter -{ -public: - aggregate_formatter() = default; +class aggregate_formatter final : public flag_formatter { + public: + aggregate_formatter() = default; - void add_ch(char ch) - { - str_ += ch; - } - void format(const details::log_msg &, const std::tm &, fmt::memory_buffer &dest) override - { - fmt_helper::append_string_view(str_, dest); - } + void add_ch(char ch) { str_ += ch; } + void format(const details::log_msg &, const std::tm &, + fmt::memory_buffer &dest) override { + fmt_helper::append_string_view(str_, dest); + } -private: - std::string str_; + private: + std::string str_; }; // mark the color range. expect it to be in the form of "%^colored text%$" -class color_start_formatter final : public flag_formatter -{ -public: - explicit color_start_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class color_start_formatter final : public flag_formatter { + public: + explicit color_start_formatter(padding_info padinfo) + : flag_formatter(padinfo) {} - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - msg.color_range_start = dest.size(); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + msg.color_range_start = dest.size(); + } }; -class color_stop_formatter final : public flag_formatter -{ -public: - explicit color_stop_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class color_stop_formatter final : public flag_formatter { + public: + explicit color_stop_formatter(padding_info padinfo) + : flag_formatter(padinfo) {} - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - msg.color_range_end = dest.size(); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + msg.color_range_end = dest.size(); + } }; // print source location -class source_location_formatter final : public flag_formatter -{ -public: - explicit source_location_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class source_location_formatter final : public flag_formatter { + public: + explicit source_location_formatter(padding_info padinfo) + : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - if (msg.source.empty()) - { - return; - } - if (padinfo_.enabled()) - { - const auto text_size = std::char_traits::length(msg.source.filename) + fmt_helper::count_digits(msg.source.line) + 1; - scoped_pad p(text_size, padinfo_, dest); - fmt_helper::append_string_view(msg.source.filename, dest); - dest.push_back(':'); - fmt_helper::append_int(msg.source.line, dest); - } - else - { - fmt_helper::append_string_view(msg.source.filename, dest); - dest.push_back(':'); - fmt_helper::append_int(msg.source.line, dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + if (msg.source.empty()) { + return; } + if (padinfo_.enabled()) { + const auto text_size = + std::char_traits::length(msg.source.filename) + + fmt_helper::count_digits(msg.source.line) + 1; + scoped_pad p(text_size, padinfo_, dest); + fmt_helper::append_string_view(msg.source.filename, dest); + dest.push_back(':'); + fmt_helper::append_int(msg.source.line, dest); + } else { + fmt_helper::append_string_view(msg.source.filename, dest); + dest.push_back(':'); + fmt_helper::append_int(msg.source.line, dest); + } + } }; // print source filename -class source_filename_formatter final : public flag_formatter -{ -public: - explicit source_filename_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class source_filename_formatter final : public flag_formatter { + public: + explicit source_filename_formatter(padding_info padinfo) + : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - if (msg.source.empty()) - { - return; - } - scoped_pad p(msg.source.filename, padinfo_, dest); - fmt_helper::append_string_view(msg.source.filename, dest); + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + if (msg.source.empty()) { + return; } + scoped_pad p(msg.source.filename, padinfo_, dest); + fmt_helper::append_string_view(msg.source.filename, dest); + } }; -class source_linenum_formatter final : public flag_formatter -{ -public: - explicit source_linenum_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class source_linenum_formatter final : public flag_formatter { + public: + explicit source_linenum_formatter(padding_info padinfo) + : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - if (msg.source.empty()) - { - return; - } - if (padinfo_.enabled()) - { - auto field_size = fmt_helper::count_digits(msg.source.line); - scoped_pad p(field_size, padinfo_, dest); - fmt_helper::append_int(msg.source.line, dest); - } - else - { - fmt_helper::append_int(msg.source.line, dest); - } + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + if (msg.source.empty()) { + return; } + if (padinfo_.enabled()) { + auto field_size = fmt_helper::count_digits(msg.source.line); + scoped_pad p(field_size, padinfo_, dest); + fmt_helper::append_int(msg.source.line, dest); + } else { + fmt_helper::append_int(msg.source.line, dest); + } + } }; // print source funcname -class source_funcname_formatter final : public flag_formatter -{ -public: - explicit source_funcname_formatter(padding_info padinfo) - : flag_formatter(padinfo){}; +class source_funcname_formatter final : public flag_formatter { + public: + explicit source_funcname_formatter(padding_info padinfo) + : flag_formatter(padinfo){}; - void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override - { - if (msg.source.empty()) - { - return; - } - scoped_pad p(msg.source.funcname, padinfo_, dest); - fmt_helper::append_string_view(msg.source.funcname, dest); + void format(const details::log_msg &msg, const std::tm &, + fmt::memory_buffer &dest) override { + if (msg.source.empty()) { + return; } + scoped_pad p(msg.source.funcname, padinfo_, dest); + fmt_helper::append_string_view(msg.source.funcname, dest); + } }; // Full info formatter // pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v -class full_formatter final : public flag_formatter -{ -public: - explicit full_formatter(padding_info padinfo) - : flag_formatter(padinfo) - { - } +class full_formatter final : public flag_formatter { + public: + explicit full_formatter(padding_info padinfo) : flag_formatter(padinfo) {} - void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) override - { - using std::chrono::duration_cast; - using std::chrono::milliseconds; - using std::chrono::seconds; + void format(const details::log_msg &msg, const std::tm &tm_time, + fmt::memory_buffer &dest) override { + using std::chrono::duration_cast; + using std::chrono::milliseconds; + using std::chrono::seconds; #ifndef SPDLOG_NO_DATETIME - // cache the date/time part for the next second. - auto duration = msg.time.time_since_epoch(); - auto secs = duration_cast(duration); + // cache the date/time part for the next second. + auto duration = msg.time.time_since_epoch(); + auto secs = duration_cast(duration); - if (cache_timestamp_ != secs || cached_datetime_.size() == 0) - { - cached_datetime_.clear(); - cached_datetime_.push_back('['); - fmt_helper::append_int(tm_time.tm_year + 1900, cached_datetime_); - cached_datetime_.push_back('-'); + if (cache_timestamp_ != secs || cached_datetime_.size() == 0) { + cached_datetime_.clear(); + cached_datetime_.push_back('['); + fmt_helper::append_int(tm_time.tm_year + 1900, cached_datetime_); + cached_datetime_.push_back('-'); - fmt_helper::pad2(tm_time.tm_mon + 1, cached_datetime_); - cached_datetime_.push_back('-'); + fmt_helper::pad2(tm_time.tm_mon + 1, cached_datetime_); + cached_datetime_.push_back('-'); - fmt_helper::pad2(tm_time.tm_mday, cached_datetime_); - cached_datetime_.push_back(' '); + fmt_helper::pad2(tm_time.tm_mday, cached_datetime_); + cached_datetime_.push_back(' '); - fmt_helper::pad2(tm_time.tm_hour, cached_datetime_); - cached_datetime_.push_back(':'); + fmt_helper::pad2(tm_time.tm_hour, cached_datetime_); + cached_datetime_.push_back(':'); - fmt_helper::pad2(tm_time.tm_min, cached_datetime_); - cached_datetime_.push_back(':'); + fmt_helper::pad2(tm_time.tm_min, cached_datetime_); + cached_datetime_.push_back(':'); - fmt_helper::pad2(tm_time.tm_sec, cached_datetime_); - cached_datetime_.push_back('.'); + fmt_helper::pad2(tm_time.tm_sec, cached_datetime_); + cached_datetime_.push_back('.'); - cache_timestamp_ = secs; - } - fmt_helper::append_buf(cached_datetime_, dest); + cache_timestamp_ = secs; + } + fmt_helper::append_buf(cached_datetime_, dest); - auto millis = fmt_helper::time_fraction(msg.time); - fmt_helper::pad3(static_cast(millis.count()), dest); - dest.push_back(']'); - dest.push_back(' '); + auto millis = fmt_helper::time_fraction(msg.time); + fmt_helper::pad3(static_cast(millis.count()), dest); + dest.push_back(']'); + dest.push_back(' '); -#else // no datetime needed - (void)tm_time; +#else // no datetime needed + (void)tm_time; #endif #ifndef SPDLOG_NO_NAME - if (!msg.logger_name->empty()) - { - dest.push_back('['); - // fmt_helper::append_str(*msg.logger_name, dest); - fmt_helper::append_string_view(*msg.logger_name, dest); - dest.push_back(']'); - dest.push_back(' '); - } + if (!msg.logger_name->empty()) { + dest.push_back('['); + // fmt_helper::append_str(*msg.logger_name, dest); + fmt_helper::append_string_view(*msg.logger_name, dest); + dest.push_back(']'); + dest.push_back(' '); + } #endif - dest.push_back('['); - // wrap the level name with color - msg.color_range_start = dest.size(); - // fmt_helper::append_string_view(level::to_c_str(msg.level), dest); - fmt_helper::append_string_view(level::to_string_view(msg.level), dest); - msg.color_range_end = dest.size(); - dest.push_back(']'); - dest.push_back(' '); + dest.push_back('['); + // wrap the level name with color + msg.color_range_start = dest.size(); + // fmt_helper::append_string_view(level::to_c_str(msg.level), dest); + fmt_helper::append_string_view(level::to_string_view(msg.level), dest); + msg.color_range_end = dest.size(); + dest.push_back(']'); + dest.push_back(' '); - // add source location if present - if (!msg.source.empty()) - { - dest.push_back('['); - fmt_helper::append_string_view(msg.source.filename, dest); - dest.push_back(':'); - fmt_helper::append_int(msg.source.line, dest); - dest.push_back(']'); - dest.push_back(' '); - } - // fmt_helper::append_string_view(msg.msg(), dest); - fmt_helper::append_string_view(msg.payload, dest); + // add source location if present + if (!msg.source.empty()) { + dest.push_back('['); + fmt_helper::append_string_view(msg.source.filename, dest); + dest.push_back(':'); + fmt_helper::append_int(msg.source.line, dest); + dest.push_back(']'); + dest.push_back(' '); } + // fmt_helper::append_string_view(msg.msg(), dest); + fmt_helper::append_string_view(msg.payload, dest); + } -private: - std::chrono::seconds cache_timestamp_{0}; - fmt::basic_memory_buffer cached_datetime_; + private: + std::chrono::seconds cache_timestamp_{0}; + fmt::basic_memory_buffer cached_datetime_; }; -} // namespace details +} // namespace details -class pattern_formatter final : public formatter -{ -public: - explicit pattern_formatter( - std::string pattern, pattern_time_type time_type = pattern_time_type::local, std::string eol = spdlog::details::os::default_eol) - : pattern_(std::move(pattern)) - , eol_(std::move(eol)) - , pattern_time_type_(time_type) - , last_log_secs_(0) - { - std::memset(&cached_tm_, 0, sizeof(cached_tm_)); - compile_pattern_(pattern_); - } +class pattern_formatter final : public formatter { + public: + explicit pattern_formatter( + std::string pattern, + pattern_time_type time_type = pattern_time_type::local, + std::string eol = spdlog::details::os::default_eol) + : pattern_(std::move(pattern)), + eol_(std::move(eol)), + pattern_time_type_(time_type), + last_log_secs_(0) { + std::memset(&cached_tm_, 0, sizeof(cached_tm_)); + compile_pattern_(pattern_); + } - // use by default full formatter for if pattern is not given - explicit pattern_formatter(pattern_time_type time_type = pattern_time_type::local, std::string eol = spdlog::details::os::default_eol) - : pattern_("%+") - , eol_(std::move(eol)) - , pattern_time_type_(time_type) - , last_log_secs_(0) - { - std::memset(&cached_tm_, 0, sizeof(cached_tm_)); - formatters_.push_back(details::make_unique(details::padding_info{})); - } + // use by default full formatter for if pattern is not given + explicit pattern_formatter( + pattern_time_type time_type = pattern_time_type::local, + std::string eol = spdlog::details::os::default_eol) + : pattern_("%+"), + eol_(std::move(eol)), + pattern_time_type_(time_type), + last_log_secs_(0) { + std::memset(&cached_tm_, 0, sizeof(cached_tm_)); + formatters_.push_back( + details::make_unique(details::padding_info{})); + } - pattern_formatter(const pattern_formatter &other) = delete; - pattern_formatter &operator=(const pattern_formatter &other) = delete; + pattern_formatter(const pattern_formatter &other) = delete; + pattern_formatter &operator=(const pattern_formatter &other) = delete; - std::unique_ptr clone() const override - { - return details::make_unique(pattern_, pattern_time_type_, eol_); - } + std::unique_ptr clone() const override { + return details::make_unique(pattern_, pattern_time_type_, + eol_); + } - void format(const details::log_msg &msg, fmt::memory_buffer &dest) override - { + void format(const details::log_msg &msg, fmt::memory_buffer &dest) override { #ifndef SPDLOG_NO_DATETIME - auto secs = std::chrono::duration_cast(msg.time.time_since_epoch()); - if (secs != last_log_secs_) - { - cached_tm_ = get_time_(msg); - last_log_secs_ = secs; - } + auto secs = std::chrono::duration_cast( + msg.time.time_since_epoch()); + if (secs != last_log_secs_) { + cached_tm_ = get_time_(msg); + last_log_secs_ = secs; + } #endif - for (auto &f : formatters_) - { - f->format(msg, cached_tm_, dest); - } - // write eol - details::fmt_helper::append_string_view(eol_, dest); + for (auto &f : formatters_) { + f->format(msg, cached_tm_, dest); } + // write eol + details::fmt_helper::append_string_view(eol_, dest); + } -private: - std::string pattern_; - std::string eol_; - pattern_time_type pattern_time_type_; - std::tm cached_tm_; - std::chrono::seconds last_log_secs_; + private: + std::string pattern_; + std::string eol_; + pattern_time_type pattern_time_type_; + std::tm cached_tm_; + std::chrono::seconds last_log_secs_; - std::vector> formatters_; + std::vector> formatters_; - std::tm get_time_(const details::log_msg &msg) - { - if (pattern_time_type_ == pattern_time_type::local) - { - return details::os::localtime(log_clock::to_time_t(msg.time)); - } - return details::os::gmtime(log_clock::to_time_t(msg.time)); + std::tm get_time_(const details::log_msg &msg) { + if (pattern_time_type_ == pattern_time_type::local) { + return details::os::localtime(log_clock::to_time_t(msg.time)); } + return details::os::gmtime(log_clock::to_time_t(msg.time)); + } - void handle_flag_(char flag, details::padding_info padding) - { - switch (flag) - { + void handle_flag_(char flag, details::padding_info padding) { + switch (flag) { + case ('+'): // default formatter + formatters_.push_back( + details::make_unique(padding)); + break; - case ('+'): // default formatter - formatters_.push_back(details::make_unique(padding)); - break; + case 'n': // logger name + formatters_.push_back( + details::make_unique(padding)); + break; - case 'n': // logger name - formatters_.push_back(details::make_unique(padding)); - break; + case 'l': // level + formatters_.push_back( + details::make_unique(padding)); + break; - case 'l': // level - formatters_.push_back(details::make_unique(padding)); - break; + case 'L': // short level + formatters_.push_back( + details::make_unique(padding)); + break; - case 'L': // short level - formatters_.push_back(details::make_unique(padding)); - break; + case ('t'): // thread id + formatters_.push_back( + details::make_unique(padding)); + break; - case ('t'): // thread id - formatters_.push_back(details::make_unique(padding)); - break; + case ('v'): // the message text + formatters_.push_back( + details::make_unique(padding)); + break; - case ('v'): // the message text - formatters_.push_back(details::make_unique(padding)); - break; + case ('a'): // weekday + formatters_.push_back( + details::make_unique(padding)); + break; - case ('a'): // weekday - formatters_.push_back(details::make_unique(padding)); - break; + case ('A'): // short weekday + formatters_.push_back( + details::make_unique(padding)); + break; - case ('A'): // short weekday - formatters_.push_back(details::make_unique(padding)); - break; + case ('b'): + case ('h'): // month + formatters_.push_back( + details::make_unique(padding)); + break; - case ('b'): - case ('h'): // month - formatters_.push_back(details::make_unique(padding)); - break; + case ('B'): // short month + formatters_.push_back( + details::make_unique(padding)); + break; - case ('B'): // short month - formatters_.push_back(details::make_unique(padding)); - break; + case ('c'): // datetime + formatters_.push_back( + details::make_unique(padding)); + break; - case ('c'): // datetime - formatters_.push_back(details::make_unique(padding)); - break; + case ('C'): // year 2 digits + formatters_.push_back( + details::make_unique(padding)); + break; - case ('C'): // year 2 digits - formatters_.push_back(details::make_unique(padding)); - break; + case ('Y'): // year 4 digits + formatters_.push_back( + details::make_unique(padding)); + break; - case ('Y'): // year 4 digits - formatters_.push_back(details::make_unique(padding)); - break; + case ('D'): + case ('x'): // datetime MM/DD/YY + formatters_.push_back( + details::make_unique(padding)); + break; - case ('D'): - case ('x'): // datetime MM/DD/YY - formatters_.push_back(details::make_unique(padding)); - break; + case ('m'): // month 1-12 + formatters_.push_back( + details::make_unique(padding)); + break; - case ('m'): // month 1-12 - formatters_.push_back(details::make_unique(padding)); - break; + case ('d'): // day of month 1-31 + formatters_.push_back( + details::make_unique(padding)); + break; - case ('d'): // day of month 1-31 - formatters_.push_back(details::make_unique(padding)); - break; + case ('H'): // hours 24 + formatters_.push_back( + details::make_unique(padding)); + break; - case ('H'): // hours 24 - formatters_.push_back(details::make_unique(padding)); - break; + case ('I'): // hours 12 + formatters_.push_back( + details::make_unique(padding)); + break; - case ('I'): // hours 12 - formatters_.push_back(details::make_unique(padding)); - break; + case ('M'): // minutes + formatters_.push_back( + details::make_unique(padding)); + break; - case ('M'): // minutes - formatters_.push_back(details::make_unique(padding)); - break; + case ('S'): // seconds + formatters_.push_back( + details::make_unique(padding)); + break; - case ('S'): // seconds - formatters_.push_back(details::make_unique(padding)); - break; + case ('e'): // milliseconds + formatters_.push_back( + details::make_unique(padding)); + break; - case ('e'): // milliseconds - formatters_.push_back(details::make_unique(padding)); - break; + case ('f'): // microseconds + formatters_.push_back( + details::make_unique(padding)); + break; - case ('f'): // microseconds - formatters_.push_back(details::make_unique(padding)); - break; + case ('F'): // nanoseconds + formatters_.push_back( + details::make_unique(padding)); + break; - case ('F'): // nanoseconds - formatters_.push_back(details::make_unique(padding)); - break; + case ('E'): // seconds since epoch + formatters_.push_back( + details::make_unique(padding)); + break; - case ('E'): // seconds since epoch - formatters_.push_back(details::make_unique(padding)); - break; + case ('p'): // am/pm + formatters_.push_back( + details::make_unique(padding)); + break; - case ('p'): // am/pm - formatters_.push_back(details::make_unique(padding)); - break; + case ('r'): // 12 hour clock 02:55:02 pm + formatters_.push_back( + details::make_unique(padding)); + break; - case ('r'): // 12 hour clock 02:55:02 pm - formatters_.push_back(details::make_unique(padding)); - break; + case ('R'): // 24-hour HH:MM time + formatters_.push_back( + details::make_unique(padding)); + break; - case ('R'): // 24-hour HH:MM time - formatters_.push_back(details::make_unique(padding)); - break; + case ('T'): + case ('X'): // ISO 8601 time format (HH:MM:SS) + formatters_.push_back( + details::make_unique(padding)); + break; - case ('T'): - case ('X'): // ISO 8601 time format (HH:MM:SS) - formatters_.push_back(details::make_unique(padding)); - break; + case ('z'): // timezone + formatters_.push_back( + details::make_unique(padding)); + break; - case ('z'): // timezone - formatters_.push_back(details::make_unique(padding)); - break; - - case ('P'): // pid - formatters_.push_back(details::make_unique(padding)); - break; + case ('P'): // pid + formatters_.push_back( + details::make_unique(padding)); + break; #ifdef SPDLOG_ENABLE_MESSAGE_COUNTER - case ('i'): - formatters_.push_back(details::make_unique(padding)); - break; + case ('i'): + formatters_.push_back( + details::make_unique(padding)); + break; #endif - case ('^'): // color range start - formatters_.push_back(details::make_unique(padding)); - break; + case ('^'): // color range start + formatters_.push_back( + details::make_unique(padding)); + break; - case ('$'): // color range end - formatters_.push_back(details::make_unique(padding)); - break; + case ('$'): // color range end + formatters_.push_back( + details::make_unique(padding)); + break; - case ('@'): // source location (filename:filenumber) - formatters_.push_back(details::make_unique(padding)); - break; + case ('@'): // source location (filename:filenumber) + formatters_.push_back( + details::make_unique(padding)); + break; - case ('s'): // source filename - formatters_.push_back(details::make_unique(padding)); - break; + case ('s'): // source filename + formatters_.push_back( + details::make_unique(padding)); + break; - case ('#'): // source line number - formatters_.push_back(details::make_unique(padding)); - break; + case ('#'): // source line number + formatters_.push_back( + details::make_unique(padding)); + break; - case ('!'): // source funcname - formatters_.push_back(details::make_unique(padding)); - break; + case ('!'): // source funcname + formatters_.push_back( + details::make_unique(padding)); + break; - case ('%'): // % char - formatters_.push_back(details::make_unique('%')); - break; + case ('%'): // % char + formatters_.push_back(details::make_unique('%')); + break; - default: // Unknown flag appears as is - auto unknown_flag = details::make_unique(); - unknown_flag->add_ch('%'); - unknown_flag->add_ch(flag); - formatters_.push_back((std::move(unknown_flag))); - break; - } + default: // Unknown flag appears as is + auto unknown_flag = + details::make_unique(); + unknown_flag->add_ch('%'); + unknown_flag->add_ch(flag); + formatters_.push_back((std::move(unknown_flag))); + break; + } + } + + // Extract given pad spec (e.g. %8X) + // Advance the given it pass the end of the padding spec found (if any) + // Return padding. + details::padding_info handle_padspec_(std::string::const_iterator &it, + std::string::const_iterator end) { + using details::padding_info; + using details::scoped_pad; + const size_t max_width = 128; + if (it == end) { + return padding_info{}; } - // Extract given pad spec (e.g. %8X) - // Advance the given it pass the end of the padding spec found (if any) - // Return padding. - details::padding_info handle_padspec_(std::string::const_iterator &it, std::string::const_iterator end) + padding_info::pad_side side; + switch (*it) { + case '-': + side = padding_info::right; + ++it; + break; + case '=': + side = padding_info::center; + ++it; + break; + default: + side = details::padding_info::left; + break; + } + + if (it == end || !std::isdigit(static_cast(*it))) { + return padding_info{0, side}; + } + + auto width = static_cast(*it - '0'); + for (++it; it != end && std::isdigit(static_cast(*it)); + ++it) { + auto digit = static_cast(*it - '0'); + width = width * 10 + digit; + } + return details::padding_info{std::min(width, max_width), side}; + } + + void compile_pattern_(const std::string &pattern) { + auto end = pattern.end(); + std::unique_ptr user_chars; + formatters_.clear(); + for (auto it = pattern.begin(); it != end; ++it) { + if (*it == '%') { + if (user_chars) // append user chars found so far + { + formatters_.push_back(std::move(user_chars)); + } + + auto padding = handle_padspec_(++it, end); + + if (it != end) { + handle_flag_(*it, padding); + } else { + break; + } + } else // chars not following the % sign should be displayed as is + { + if (!user_chars) { + user_chars = details::make_unique(); + } + user_chars->add_ch(*it); + } + } + if (user_chars) // append raw chars found so far { - using details::padding_info; - using details::scoped_pad; - const size_t max_width = 128; - if (it == end) - { - return padding_info{}; - } - - padding_info::pad_side side; - switch (*it) - { - case '-': - side = padding_info::right; - ++it; - break; - case '=': - side = padding_info::center; - ++it; - break; - default: - side = details::padding_info::left; - break; - } - - if (it == end || !std::isdigit(static_cast(*it))) - { - return padding_info{0, side}; - } - - auto width = static_cast(*it - '0'); - for (++it; it != end && std::isdigit(static_cast(*it)); ++it) - { - auto digit = static_cast(*it - '0'); - width = width * 10 + digit; - } - return details::padding_info{std::min(width, max_width), side}; - } - - void compile_pattern_(const std::string &pattern) - { - auto end = pattern.end(); - std::unique_ptr user_chars; - formatters_.clear(); - for (auto it = pattern.begin(); it != end; ++it) - { - if (*it == '%') - { - if (user_chars) // append user chars found so far - { - formatters_.push_back(std::move(user_chars)); - } - - auto padding = handle_padspec_(++it, end); - - if (it != end) - { - handle_flag_(*it, padding); - } - else - { - break; - } - } - else // chars not following the % sign should be displayed as is - { - if (!user_chars) - { - user_chars = details::make_unique(); - } - user_chars->add_ch(*it); - } - } - if (user_chars) // append raw chars found so far - { - formatters_.push_back(std::move(user_chars)); - } + formatters_.push_back(std::move(user_chars)); } + } }; -} // namespace spdlog +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/periodic_worker.h b/src/cpp/include/deps/spdlog/details/periodic_worker.h old mode 100755 new mode 100644 index fa6488d17..f12f7c185 --- a/src/cpp/include/deps/spdlog/details/periodic_worker.h +++ b/src/cpp/include/deps/spdlog/details/periodic_worker.h @@ -10,7 +10,8 @@ // // RAII over the owned thread: // creates the thread on construction. -// stops and joins the thread on destruction (if the thread is executing a callback, wait for it to finish first). +// stops and joins the thread on destruction (if the thread is executing a +// callback, wait for it to finish first). #include #include @@ -20,52 +21,47 @@ namespace spdlog { namespace details { -class periodic_worker -{ -public: - periodic_worker(const std::function &callback_fun, std::chrono::seconds interval) - { - active_ = (interval > std::chrono::seconds::zero()); - if (!active_) - { - return; - } - - worker_thread_ = std::thread([this, callback_fun, interval]() { - for (;;) - { - std::unique_lock lock(this->mutex_); - if (this->cv_.wait_for(lock, interval, [this] { return !this->active_; })) - { - return; // active_ == false, so exit this thread - } - callback_fun(); - } - }); +class periodic_worker { + public: + periodic_worker(const std::function &callback_fun, + std::chrono::seconds interval) { + active_ = (interval > std::chrono::seconds::zero()); + if (!active_) { + return; } - periodic_worker(const periodic_worker &) = delete; - periodic_worker &operator=(const periodic_worker &) = delete; - - // stop the worker thread and join it - ~periodic_worker() - { - if (worker_thread_.joinable()) - { - { - std::lock_guard lock(mutex_); - active_ = false; - } - cv_.notify_one(); - worker_thread_.join(); + worker_thread_ = std::thread([this, callback_fun, interval]() { + for (;;) { + std::unique_lock lock(this->mutex_); + if (this->cv_.wait_for(lock, interval, + [this] { return !this->active_; })) { + return; // active_ == false, so exit this thread } - } + callback_fun(); + } + }); + } -private: - bool active_; - std::thread worker_thread_; - std::mutex mutex_; - std::condition_variable cv_; + periodic_worker(const periodic_worker &) = delete; + periodic_worker &operator=(const periodic_worker &) = delete; + + // stop the worker thread and join it + ~periodic_worker() { + if (worker_thread_.joinable()) { + { + std::lock_guard lock(mutex_); + active_ = false; + } + cv_.notify_one(); + worker_thread_.join(); + } + } + + private: + bool active_; + std::thread worker_thread_; + std::mutex mutex_; + std::condition_variable cv_; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/registry.h b/src/cpp/include/deps/spdlog/details/registry.h old mode 100755 new mode 100644 index ccd539557..041249ca1 --- a/src/cpp/include/deps/spdlog/details/registry.h +++ b/src/cpp/include/deps/spdlog/details/registry.h @@ -21,7 +21,7 @@ #else #include "spdlog/sinks/ansicolor_sink.h" #endif -#endif // SPDLOG_DISABLE_DEFAULT_LOGGER +#endif // SPDLOG_DISABLE_DEFAULT_LOGGER #include #include @@ -33,253 +33,216 @@ namespace spdlog { namespace details { class thread_pool; -class registry -{ -public: - registry(const registry &) = delete; - registry &operator=(const registry &) = delete; +class registry { + public: + registry(const registry &) = delete; + registry &operator=(const registry &) = delete; - void register_logger(std::shared_ptr new_logger) - { - std::lock_guard lock(logger_map_mutex_); - register_logger_(std::move(new_logger)); + void register_logger(std::shared_ptr new_logger) { + std::lock_guard lock(logger_map_mutex_); + register_logger_(std::move(new_logger)); + } + + void initialize_logger(std::shared_ptr new_logger) { + std::lock_guard lock(logger_map_mutex_); + new_logger->set_formatter(formatter_->clone()); + + if (err_handler_) { + new_logger->set_error_handler(err_handler_); } - void initialize_logger(std::shared_ptr new_logger) + new_logger->set_level(level_); + new_logger->flush_on(flush_level_); + + if (automatic_registration_) { + register_logger_(std::move(new_logger)); + } + } + + std::shared_ptr get(const std::string &logger_name) { + std::lock_guard lock(logger_map_mutex_); + auto found = loggers_.find(logger_name); + return found == loggers_.end() ? nullptr : found->second; + } + + std::shared_ptr default_logger() { + std::lock_guard lock(logger_map_mutex_); + return default_logger_; + } + + // Return raw ptr to the default logger. + // To be used directly by the spdlog default api (e.g. spdlog::info) + // This make the default API faster, but cannot be used concurrently with + // set_default_logger(). e.g do not call set_default_logger() from one thread + // while calling spdlog::info() from another. + logger *get_default_raw() { return default_logger_.get(); } + + // set default logger. + // default logger is stored in default_logger_ (for faster retrieval) and in + // the loggers_ map. + void set_default_logger(std::shared_ptr new_default_logger) { + std::lock_guard lock(logger_map_mutex_); + // remove previous default logger from the map + if (default_logger_ != nullptr) { + loggers_.erase(default_logger_->name()); + } + if (new_default_logger != nullptr) { + loggers_[new_default_logger->name()] = new_default_logger; + } + default_logger_ = std::move(new_default_logger); + } + + void set_tp(std::shared_ptr tp) { + std::lock_guard lock(tp_mutex_); + tp_ = std::move(tp); + } + + std::shared_ptr get_tp() { + std::lock_guard lock(tp_mutex_); + return tp_; + } + + // Set global formatter. Each sink in each logger will get a clone of this + // object + void set_formatter(std::unique_ptr formatter) { + std::lock_guard lock(logger_map_mutex_); + formatter_ = std::move(formatter); + for (auto &l : loggers_) { + l.second->set_formatter(formatter_->clone()); + } + } + + void set_level(level::level_enum log_level) { + std::lock_guard lock(logger_map_mutex_); + for (auto &l : loggers_) { + l.second->set_level(log_level); + } + level_ = log_level; + } + + void flush_on(level::level_enum log_level) { + std::lock_guard lock(logger_map_mutex_); + for (auto &l : loggers_) { + l.second->flush_on(log_level); + } + flush_level_ = log_level; + } + + void flush_every(std::chrono::seconds interval) { + std::lock_guard lock(flusher_mutex_); + std::function clbk = std::bind(®istry::flush_all, this); + periodic_flusher_ = details::make_unique(clbk, interval); + } + + void set_error_handler(log_err_handler handler) { + std::lock_guard lock(logger_map_mutex_); + for (auto &l : loggers_) { + l.second->set_error_handler(handler); + } + err_handler_ = handler; + } + + void apply_all( + const std::function)> &fun) { + std::lock_guard lock(logger_map_mutex_); + for (auto &l : loggers_) { + fun(l.second); + } + } + + void flush_all() { + std::lock_guard lock(logger_map_mutex_); + for (auto &l : loggers_) { + l.second->flush(); + } + } + + void drop(const std::string &logger_name) { + std::lock_guard lock(logger_map_mutex_); + loggers_.erase(logger_name); + if (default_logger_ && default_logger_->name() == logger_name) { + default_logger_.reset(); + } + } + + void drop_all() { + std::lock_guard lock(logger_map_mutex_); + loggers_.clear(); + default_logger_.reset(); + } + + // clean all resources and threads started by the registry + void shutdown() { { - std::lock_guard lock(logger_map_mutex_); - new_logger->set_formatter(formatter_->clone()); - - if (err_handler_) - { - new_logger->set_error_handler(err_handler_); - } - - new_logger->set_level(level_); - new_logger->flush_on(flush_level_); - - if (automatic_registration_) - { - register_logger_(std::move(new_logger)); - } + std::lock_guard lock(flusher_mutex_); + periodic_flusher_.reset(); } - std::shared_ptr get(const std::string &logger_name) + drop_all(); + { - std::lock_guard lock(logger_map_mutex_); - auto found = loggers_.find(logger_name); - return found == loggers_.end() ? nullptr : found->second; + std::lock_guard lock(tp_mutex_); + tp_.reset(); } + } - std::shared_ptr default_logger() - { - std::lock_guard lock(logger_map_mutex_); - return default_logger_; - } + std::recursive_mutex &tp_mutex() { return tp_mutex_; } - // Return raw ptr to the default logger. - // To be used directly by the spdlog default api (e.g. spdlog::info) - // This make the default API faster, but cannot be used concurrently with set_default_logger(). - // e.g do not call set_default_logger() from one thread while calling spdlog::info() from another. - logger *get_default_raw() - { - return default_logger_.get(); - } + void set_automatic_registration(bool automatic_regsistration) { + std::lock_guard lock(logger_map_mutex_); + automatic_registration_ = automatic_regsistration; + } - // set default logger. - // default logger is stored in default_logger_ (for faster retrieval) and in the loggers_ map. - void set_default_logger(std::shared_ptr new_default_logger) - { - std::lock_guard lock(logger_map_mutex_); - // remove previous default logger from the map - if (default_logger_ != nullptr) - { - loggers_.erase(default_logger_->name()); - } - if (new_default_logger != nullptr) - { - loggers_[new_default_logger->name()] = new_default_logger; - } - default_logger_ = std::move(new_default_logger); - } - - void set_tp(std::shared_ptr tp) - { - std::lock_guard lock(tp_mutex_); - tp_ = std::move(tp); - } - - std::shared_ptr get_tp() - { - std::lock_guard lock(tp_mutex_); - return tp_; - } - - // Set global formatter. Each sink in each logger will get a clone of this object - void set_formatter(std::unique_ptr formatter) - { - std::lock_guard lock(logger_map_mutex_); - formatter_ = std::move(formatter); - for (auto &l : loggers_) - { - l.second->set_formatter(formatter_->clone()); - } - } - - void set_level(level::level_enum log_level) - { - std::lock_guard lock(logger_map_mutex_); - for (auto &l : loggers_) - { - l.second->set_level(log_level); - } - level_ = log_level; - } - - void flush_on(level::level_enum log_level) - { - std::lock_guard lock(logger_map_mutex_); - for (auto &l : loggers_) - { - l.second->flush_on(log_level); - } - flush_level_ = log_level; - } - - void flush_every(std::chrono::seconds interval) - { - std::lock_guard lock(flusher_mutex_); - std::function clbk = std::bind(®istry::flush_all, this); - periodic_flusher_ = details::make_unique(clbk, interval); - } - - void set_error_handler(log_err_handler handler) - { - std::lock_guard lock(logger_map_mutex_); - for (auto &l : loggers_) - { - l.second->set_error_handler(handler); - } - err_handler_ = handler; - } - - void apply_all(const std::function)> &fun) - { - std::lock_guard lock(logger_map_mutex_); - for (auto &l : loggers_) - { - fun(l.second); - } - } - - void flush_all() - { - std::lock_guard lock(logger_map_mutex_); - for (auto &l : loggers_) - { - l.second->flush(); - } - } - - void drop(const std::string &logger_name) - { - std::lock_guard lock(logger_map_mutex_); - loggers_.erase(logger_name); - if (default_logger_ && default_logger_->name() == logger_name) - { - default_logger_.reset(); - } - } - - void drop_all() - { - std::lock_guard lock(logger_map_mutex_); - loggers_.clear(); - default_logger_.reset(); - } - - // clean all resources and threads started by the registry - void shutdown() - { - { - std::lock_guard lock(flusher_mutex_); - periodic_flusher_.reset(); - } - - drop_all(); - - { - std::lock_guard lock(tp_mutex_); - tp_.reset(); - } - } - - std::recursive_mutex &tp_mutex() - { - return tp_mutex_; - } - - void set_automatic_registration(bool automatic_regsistration) - { - std::lock_guard lock(logger_map_mutex_); - automatic_registration_ = automatic_regsistration; - } - - static registry &instance() - { - static registry s_instance; - return s_instance; - } - -private: - registry() - : formatter_(new pattern_formatter()) - { + static registry &instance() { + static registry s_instance; + return s_instance; + } + private: + registry() : formatter_(new pattern_formatter()) { #ifndef SPDLOG_DISABLE_DEFAULT_LOGGER - // create default logger (ansicolor_stdout_sink_mt or wincolor_stdout_sink_mt in windows). + // create default logger (ansicolor_stdout_sink_mt or + // wincolor_stdout_sink_mt in windows). #ifdef _WIN32 - auto color_sink = std::make_shared(); + auto color_sink = std::make_shared(); #else - auto color_sink = std::make_shared(); + auto color_sink = std::make_shared(); #endif - const char *default_logger_name = ""; - default_logger_ = std::make_shared(default_logger_name, std::move(color_sink)); - loggers_[default_logger_name] = default_logger_; + const char *default_logger_name = ""; + default_logger_ = std::make_shared(default_logger_name, + std::move(color_sink)); + loggers_[default_logger_name] = default_logger_; -#endif // SPDLOG_DISABLE_DEFAULT_LOGGER +#endif // SPDLOG_DISABLE_DEFAULT_LOGGER + } + + ~registry() = default; + + void throw_if_exists_(const std::string &logger_name) { + if (loggers_.find(logger_name) != loggers_.end()) { + throw spdlog_ex("logger with name '" + logger_name + "' already exists"); } + } - ~registry() = default; + void register_logger_(std::shared_ptr new_logger) { + auto logger_name = new_logger->name(); + throw_if_exists_(logger_name); + loggers_[logger_name] = std::move(new_logger); + } - void throw_if_exists_(const std::string &logger_name) - { - if (loggers_.find(logger_name) != loggers_.end()) - { - throw spdlog_ex("logger with name '" + logger_name + "' already exists"); - } - } - - void register_logger_(std::shared_ptr new_logger) - { - auto logger_name = new_logger->name(); - throw_if_exists_(logger_name); - loggers_[logger_name] = std::move(new_logger); - } - - std::mutex logger_map_mutex_, flusher_mutex_; - std::recursive_mutex tp_mutex_; - std::unordered_map> loggers_; - std::unique_ptr formatter_; - level::level_enum level_ = spdlog::logger::default_level(); - level::level_enum flush_level_ = level::off; - log_err_handler err_handler_; - std::shared_ptr tp_; - std::unique_ptr periodic_flusher_; - std::shared_ptr default_logger_; - bool automatic_registration_ = true; + std::mutex logger_map_mutex_, flusher_mutex_; + std::recursive_mutex tp_mutex_; + std::unordered_map> loggers_; + std::unique_ptr formatter_; + level::level_enum level_ = spdlog::logger::default_level(); + level::level_enum flush_level_ = level::off; + log_err_handler err_handler_; + std::shared_ptr tp_; + std::unique_ptr periodic_flusher_; + std::shared_ptr default_logger_; + bool automatic_registration_ = true; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/details/thread_pool.h b/src/cpp/include/deps/spdlog/details/thread_pool.h old mode 100755 new mode 100644 index 35578971a..7f6efd9ce --- a/src/cpp/include/deps/spdlog/details/thread_pool.h +++ b/src/cpp/include/deps/spdlog/details/thread_pool.h @@ -1,238 +1,206 @@ #pragma once -#include "spdlog/details/fmt_helper.h" -#include "spdlog/details/log_msg.h" -#include "spdlog/details/mpmc_blocking_q.h" -#include "spdlog/details/os.h" - #include #include #include #include +#include "spdlog/details/fmt_helper.h" +#include "spdlog/details/log_msg.h" +#include "spdlog/details/mpmc_blocking_q.h" +#include "spdlog/details/os.h" + namespace spdlog { namespace details { using async_logger_ptr = std::shared_ptr; -enum class async_msg_type -{ - log, - flush, - terminate -}; +enum class async_msg_type { log, flush, terminate }; // Async msg to move to/from the queue // Movable only. should never be copied -struct async_msg -{ - async_msg_type msg_type; - level::level_enum level; - log_clock::time_point time; - size_t thread_id; - fmt::basic_memory_buffer raw; +struct async_msg { + async_msg_type msg_type; + level::level_enum level; + log_clock::time_point time; + size_t thread_id; + fmt::basic_memory_buffer raw; - size_t msg_id; - source_loc source; - async_logger_ptr worker_ptr; + size_t msg_id; + source_loc source; + async_logger_ptr worker_ptr; - async_msg() = default; - ~async_msg() = default; + async_msg() = default; + ~async_msg() = default; - // should only be moved in or out of the queue.. - async_msg(const async_msg &) = delete; + // should only be moved in or out of the queue.. + async_msg(const async_msg &) = delete; // support for vs2013 move #if defined(_MSC_VER) && _MSC_VER <= 1800 - async_msg(async_msg &&other) SPDLOG_NOEXCEPT : msg_type(other.msg_type), - level(other.level), - time(other.time), - thread_id(other.thread_id), - raw(move(other.raw)), - msg_id(other.msg_id), - source(other.source), - worker_ptr(std::move(other.worker_ptr)) - { - } + async_msg(async_msg &&other) SPDLOG_NOEXCEPT + : msg_type(other.msg_type), + level(other.level), + time(other.time), + thread_id(other.thread_id), + raw(move(other.raw)), + msg_id(other.msg_id), + source(other.source), + worker_ptr(std::move(other.worker_ptr)) {} - async_msg &operator=(async_msg &&other) SPDLOG_NOEXCEPT - { - msg_type = other.msg_type; - level = other.level; - time = other.time; - thread_id = other.thread_id; - raw = std::move(other.raw); - msg_id = other.msg_id; - source = other.source; - worker_ptr = std::move(other.worker_ptr); - return *this; - } -#else // (_MSC_VER) && _MSC_VER <= 1800 - async_msg(async_msg &&) = default; - async_msg &operator=(async_msg &&) = default; + async_msg &operator=(async_msg &&other) SPDLOG_NOEXCEPT { + msg_type = other.msg_type; + level = other.level; + time = other.time; + thread_id = other.thread_id; + raw = std::move(other.raw); + msg_id = other.msg_id; + source = other.source; + worker_ptr = std::move(other.worker_ptr); + return *this; + } +#else // (_MSC_VER) && _MSC_VER <= 1800 + async_msg(async_msg &&) = default; + async_msg &operator=(async_msg &&) = default; #endif - // construct from log_msg with given type - async_msg(async_logger_ptr &&worker, async_msg_type the_type, details::log_msg &m) - : msg_type(the_type) - , level(m.level) - , time(m.time) - , thread_id(m.thread_id) - , msg_id(m.msg_id) - , source(m.source) - , worker_ptr(std::move(worker)) - { - fmt_helper::append_string_view(m.payload, raw); - } + // construct from log_msg with given type + async_msg(async_logger_ptr &&worker, async_msg_type the_type, + details::log_msg &m) + : msg_type(the_type), + level(m.level), + time(m.time), + thread_id(m.thread_id), + msg_id(m.msg_id), + source(m.source), + worker_ptr(std::move(worker)) { + fmt_helper::append_string_view(m.payload, raw); + } - async_msg(async_logger_ptr &&worker, async_msg_type the_type) - : msg_type(the_type) - , level(level::off) - , time() - , thread_id(0) - , msg_id(0) - , source() - , worker_ptr(std::move(worker)) - { - } + async_msg(async_logger_ptr &&worker, async_msg_type the_type) + : msg_type(the_type), + level(level::off), + time(), + thread_id(0), + msg_id(0), + source(), + worker_ptr(std::move(worker)) {} - explicit async_msg(async_msg_type the_type) - : async_msg(nullptr, the_type) - { - } + explicit async_msg(async_msg_type the_type) : async_msg(nullptr, the_type) {} - // copy into log_msg - log_msg to_log_msg() - { - log_msg msg(&worker_ptr->name(), level, string_view_t(raw.data(), raw.size())); - msg.time = time; - msg.thread_id = thread_id; - msg.msg_id = msg_id; - msg.source = source; - msg.color_range_start = 0; - msg.color_range_end = 0; - return msg; - } + // copy into log_msg + log_msg to_log_msg() { + log_msg msg(&worker_ptr->name(), level, + string_view_t(raw.data(), raw.size())); + msg.time = time; + msg.thread_id = thread_id; + msg.msg_id = msg_id; + msg.source = source; + msg.color_range_start = 0; + msg.color_range_end = 0; + return msg; + } }; -class thread_pool -{ -public: - using item_type = async_msg; - using q_type = details::mpmc_blocking_queue; +class thread_pool { + public: + using item_type = async_msg; + using q_type = details::mpmc_blocking_queue; - thread_pool(size_t q_max_items, size_t threads_n) - : q_(q_max_items) - { - // std::cout << "thread_pool() q_size_bytes: " << q_size_bytes << - // "\tthreads_n: " << threads_n << std::endl; - if (threads_n == 0 || threads_n > 1000) - { - throw spdlog_ex("spdlog::thread_pool(): invalid threads_n param (valid " - "range is 1-1000)"); - } - for (size_t i = 0; i < threads_n; i++) - { - threads_.emplace_back(&thread_pool::worker_loop_, this); - } + thread_pool(size_t q_max_items, size_t threads_n) : q_(q_max_items) { + // std::cout << "thread_pool() q_size_bytes: " << q_size_bytes << + // "\tthreads_n: " << threads_n << std::endl; + if (threads_n == 0 || threads_n > 1000) { + throw spdlog_ex( + "spdlog::thread_pool(): invalid threads_n param (valid " + "range is 1-1000)"); + } + for (size_t i = 0; i < threads_n; i++) { + threads_.emplace_back(&thread_pool::worker_loop_, this); + } + } + + // message all threads to terminate gracefully join them + ~thread_pool() { + try { + for (size_t i = 0; i < threads_.size(); i++) { + post_async_msg_(async_msg(async_msg_type::terminate), + async_overflow_policy::block); + } + + for (auto &t : threads_) { + t.join(); + } + } catch (...) { + } + } + + thread_pool(const thread_pool &) = delete; + thread_pool &operator=(thread_pool &&) = delete; + + void post_log(async_logger_ptr &&worker_ptr, details::log_msg &msg, + async_overflow_policy overflow_policy) { + async_msg async_m(std::move(worker_ptr), async_msg_type::log, msg); + post_async_msg_(std::move(async_m), overflow_policy); + } + + void post_flush(async_logger_ptr &&worker_ptr, + async_overflow_policy overflow_policy) { + post_async_msg_(async_msg(std::move(worker_ptr), async_msg_type::flush), + overflow_policy); + } + + size_t overrun_counter() { return q_.overrun_counter(); } + + private: + q_type q_; + + std::vector threads_; + + void post_async_msg_(async_msg &&new_msg, + async_overflow_policy overflow_policy) { + if (overflow_policy == async_overflow_policy::block) { + q_.enqueue(std::move(new_msg)); + } else { + q_.enqueue_nowait(std::move(new_msg)); + } + } + + void worker_loop_() { + while (process_next_msg_()) { + }; + } + + // process next message in the queue + // return true if this thread should still be active (while no terminate msg + // was received) + bool process_next_msg_() { + async_msg incoming_async_msg; + bool dequeued = + q_.dequeue_for(incoming_async_msg, std::chrono::seconds(10)); + if (!dequeued) { + return true; } - // message all threads to terminate gracefully join them - ~thread_pool() - { - try - { - for (size_t i = 0; i < threads_.size(); i++) - { - post_async_msg_(async_msg(async_msg_type::terminate), async_overflow_policy::block); - } - - for (auto &t : threads_) - { - t.join(); - } - } - catch (...) - { - } - } - - thread_pool(const thread_pool &) = delete; - thread_pool &operator=(thread_pool &&) = delete; - - void post_log(async_logger_ptr &&worker_ptr, details::log_msg &msg, async_overflow_policy overflow_policy) - { - async_msg async_m(std::move(worker_ptr), async_msg_type::log, msg); - post_async_msg_(std::move(async_m), overflow_policy); - } - - void post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy) - { - post_async_msg_(async_msg(std::move(worker_ptr), async_msg_type::flush), overflow_policy); - } - - size_t overrun_counter() - { - return q_.overrun_counter(); - } - -private: - q_type q_; - - std::vector threads_; - - void post_async_msg_(async_msg &&new_msg, async_overflow_policy overflow_policy) - { - if (overflow_policy == async_overflow_policy::block) - { - q_.enqueue(std::move(new_msg)); - } - else - { - q_.enqueue_nowait(std::move(new_msg)); - } - } - - void worker_loop_() - { - while (process_next_msg_()) {}; - } - - // process next message in the queue - // return true if this thread should still be active (while no terminate msg - // was received) - bool process_next_msg_() - { - async_msg incoming_async_msg; - bool dequeued = q_.dequeue_for(incoming_async_msg, std::chrono::seconds(10)); - if (!dequeued) - { - return true; - } - - switch (incoming_async_msg.msg_type) - { - case async_msg_type::log: - { - auto msg = incoming_async_msg.to_log_msg(); - incoming_async_msg.worker_ptr->backend_log_(msg); - return true; - } - case async_msg_type::flush: - { - incoming_async_msg.worker_ptr->backend_flush_(); - return true; - } - - case async_msg_type::terminate: - { - return false; - } - } - assert(false && "Unexpected async_msg_type"); + switch (incoming_async_msg.msg_type) { + case async_msg_type::log: { + auto msg = incoming_async_msg.to_log_msg(); + incoming_async_msg.worker_ptr->backend_log_(msg); return true; + } + case async_msg_type::flush: { + incoming_async_msg.worker_ptr->backend_flush_(); + return true; + } + + case async_msg_type::terminate: { + return false; + } } + assert(false && "Unexpected async_msg_type"); + return true; + } }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/src/cpp/include/deps/spdlog/fmt/bin_to_hex.h b/src/cpp/include/deps/spdlog/fmt/bin_to_hex.h old mode 100755 new mode 100644 index 352338020..4ad070f1f --- a/src/cpp/include/deps/spdlog/fmt/bin_to_hex.h +++ b/src/cpp/include/deps/spdlog/fmt/bin_to_hex.h @@ -19,154 +19,135 @@ // std::vector v(200, 0x0b); // logger->info("Some buffer {}", spdlog::to_hex(v)); // char buf[128]; -// logger->info("Some buffer {:X}", spdlog::to_hex(std::begin(buf), std::end(buf))); +// logger->info("Some buffer {:X}", spdlog::to_hex(std::begin(buf), +// std::end(buf))); namespace spdlog { namespace details { -template -class bytes_range -{ -public: - bytes_range(It range_begin, It range_end) - : begin_(range_begin) - , end_(range_end) - { - } +template +class bytes_range { + public: + bytes_range(It range_begin, It range_end) + : begin_(range_begin), end_(range_end) {} - It begin() const - { - return begin_; - } - It end() const - { - return end_; - } + It begin() const { return begin_; } + It end() const { return end_; } -private: - It begin_, end_; + private: + It begin_, end_; }; -} // namespace details +} // namespace details // create a bytes_range that wraps the given container -template -inline details::bytes_range to_hex(const Container &container) -{ - static_assert(sizeof(typename Container::value_type) == 1, "sizeof(Container::value_type) != 1"); - using Iter = typename Container::const_iterator; - return details::bytes_range(std::begin(container), std::end(container)); +template +inline details::bytes_range to_hex( + const Container &container) { + static_assert(sizeof(typename Container::value_type) == 1, + "sizeof(Container::value_type) != 1"); + using Iter = typename Container::const_iterator; + return details::bytes_range(std::begin(container), std::end(container)); } // create bytes_range from ranges -template -inline details::bytes_range to_hex(const It range_begin, const It range_end) -{ - return details::bytes_range(range_begin, range_end); +template +inline details::bytes_range to_hex(const It range_begin, + const It range_end) { + return details::bytes_range(range_begin, range_end); } -} // namespace spdlog +} // namespace spdlog namespace fmt { -template -struct formatter> -{ - const std::size_t line_size = 100; - const char delimiter = ' '; +template +struct formatter> { + const std::size_t line_size = 100; + const char delimiter = ' '; - bool put_newlines = true; - bool put_delimiters = true; - bool use_uppercase = false; - bool put_positions = true; // position on start of each line + bool put_newlines = true; + bool put_delimiters = true; + bool use_uppercase = false; + bool put_positions = true; // position on start of each line - // parse the format string flags - template - auto parse(ParseContext &ctx) -> decltype(ctx.begin()) - { - auto it = ctx.begin(); - while (*it && *it != '}') - { - switch (*it) - { - case 'X': - use_uppercase = true; - break; - case 's': - put_delimiters = false; - break; - case 'p': - put_positions = false; - break; - case 'n': - put_newlines = false; - break; - } + // parse the format string flags + template + auto parse(ParseContext &ctx) -> decltype(ctx.begin()) { + auto it = ctx.begin(); + while (*it && *it != '}') { + switch (*it) { + case 'X': + use_uppercase = true; + break; + case 's': + put_delimiters = false; + break; + case 'p': + put_positions = false; + break; + case 'n': + put_newlines = false; + break; + } - ++it; - } - return it; + ++it; } + return it; + } - // format the given bytes range as hex - template - auto format(const spdlog::details::bytes_range &the_range, FormatContext &ctx) -> decltype(ctx.out()) - { - SPDLOG_CONSTEXPR const char *hex_upper = "0123456789ABCDEF"; - SPDLOG_CONSTEXPR const char *hex_lower = "0123456789abcdef"; - const char *hex_chars = use_uppercase ? hex_upper : hex_lower; + // format the given bytes range as hex + template + auto format(const spdlog::details::bytes_range &the_range, + FormatContext &ctx) -> decltype(ctx.out()) { + SPDLOG_CONSTEXPR const char *hex_upper = "0123456789ABCDEF"; + SPDLOG_CONSTEXPR const char *hex_lower = "0123456789abcdef"; + const char *hex_chars = use_uppercase ? hex_upper : hex_lower; - std::size_t pos = 0; - std::size_t column = line_size; - auto inserter = ctx.begin(); + std::size_t pos = 0; + std::size_t column = line_size; + auto inserter = ctx.begin(); - for (auto &item : the_range) - { - auto ch = static_cast(item); - pos++; + for (auto &item : the_range) { + auto ch = static_cast(item); + pos++; - if (put_newlines && column >= line_size) - { - column = put_newline(inserter, pos); + if (put_newlines && column >= line_size) { + column = put_newline(inserter, pos); - // put first byte without delimiter in front of it - *inserter++ = hex_chars[(ch >> 4) & 0x0f]; - *inserter++ = hex_chars[ch & 0x0f]; - column += 2; - continue; - } + // put first byte without delimiter in front of it + *inserter++ = hex_chars[(ch >> 4) & 0x0f]; + *inserter++ = hex_chars[ch & 0x0f]; + column += 2; + continue; + } - if (put_delimiters) - { - *inserter++ = delimiter; - ++column; - } + if (put_delimiters) { + *inserter++ = delimiter; + ++column; + } - *inserter++ = hex_chars[(ch >> 4) & 0x0f]; - *inserter++ = hex_chars[ch & 0x0f]; - column += 2; - } - return inserter; + *inserter++ = hex_chars[(ch >> 4) & 0x0f]; + *inserter++ = hex_chars[ch & 0x0f]; + column += 2; } + return inserter; + } - // put newline(and position header) - // return the next column - template - std::size_t put_newline(It inserter, std::size_t pos) - { + // put newline(and position header) + // return the next column + template + std::size_t put_newline(It inserter, std::size_t pos) { #ifdef _WIN32 - *inserter++ = '\r'; + *inserter++ = '\r'; #endif - *inserter++ = '\n'; + *inserter++ = '\n'; - if (put_positions) - { - fmt::format_to(inserter, "{:<04X}: ", pos - 1); - return 7; - } - else - { - return 1; - } + if (put_positions) { + fmt::format_to(inserter, "{:<04X}: ", pos - 1); + return 7; + } else { + return 1; } + } }; -} // namespace fmt +} // namespace fmt diff --git a/src/cpp/include/deps/spdlog/fmt/bundled/chrono.h b/src/cpp/include/deps/spdlog/fmt/bundled/chrono.h old mode 100755 new mode 100644 index 209cdc25a..7db5363fd --- a/src/cpp/include/deps/spdlog/fmt/bundled/chrono.h +++ b/src/cpp/include/deps/spdlog/fmt/bundled/chrono.h @@ -8,17 +8,17 @@ #ifndef FMT_CHRONO_H_ #define FMT_CHRONO_H_ -#include "format.h" -#include "locale.h" - #include #include #include #include +#include "format.h" +#include "locale.h" + FMT_BEGIN_NAMESPACE -namespace internal{ +namespace internal { enum class numeric_system { standard, @@ -28,8 +28,9 @@ enum class numeric_system { // Parses a put_time-like format string and invokes handler actions. template -FMT_CONSTEXPR const Char *parse_chrono_format( - const Char *begin, const Char *end, Handler &&handler) { +FMT_CONSTEXPR const Char *parse_chrono_format(const Char *begin, + const Char *end, + Handler &&handler) { auto ptr = begin; while (ptr != end) { auto c = *ptr; @@ -38,147 +39,142 @@ FMT_CONSTEXPR const Char *parse_chrono_format( ++ptr; continue; } - if (begin != ptr) - handler.on_text(begin, ptr); - ++ptr; // consume '%' - if (ptr == end) - throw format_error("invalid format"); + if (begin != ptr) handler.on_text(begin, ptr); + ++ptr; // consume '%' + if (ptr == end) throw format_error("invalid format"); c = *ptr++; switch (c) { - case '%': - handler.on_text(ptr - 1, ptr); - break; - case 'n': { - const char newline[] = "\n"; - handler.on_text(newline, newline + 1); - break; - } - case 't': { - const char tab[] = "\t"; - handler.on_text(tab, tab + 1); - break; - } - // Day of the week: - case 'a': - handler.on_abbr_weekday(); - break; - case 'A': - handler.on_full_weekday(); - break; - case 'w': - handler.on_dec0_weekday(numeric_system::standard); - break; - case 'u': - handler.on_dec1_weekday(numeric_system::standard); - break; - // Month: - case 'b': - handler.on_abbr_month(); - break; - case 'B': - handler.on_full_month(); - break; - // Hour, minute, second: - case 'H': - handler.on_24_hour(numeric_system::standard); - break; - case 'I': - handler.on_12_hour(numeric_system::standard); - break; - case 'M': - handler.on_minute(numeric_system::standard); - break; - case 'S': - handler.on_second(numeric_system::standard); - break; - // Other: - case 'c': - handler.on_datetime(numeric_system::standard); - break; - case 'x': - handler.on_loc_date(numeric_system::standard); - break; - case 'X': - handler.on_loc_time(numeric_system::standard); - break; - case 'D': - handler.on_us_date(); - break; - case 'F': - handler.on_iso_date(); - break; - case 'r': - handler.on_12_hour_time(); - break; - case 'R': - handler.on_24_hour_time(); - break; - case 'T': - handler.on_iso_time(); - break; - case 'p': - handler.on_am_pm(); - break; - case 'z': - handler.on_utc_offset(); - break; - case 'Z': - handler.on_tz_name(); - break; - // Alternative representation: - case 'E': { - if (ptr == end) - throw format_error("invalid format"); - c = *ptr++; - switch (c) { - case 'c': - handler.on_datetime(numeric_system::alternative); + case '%': + handler.on_text(ptr - 1, ptr); break; - case 'x': - handler.on_loc_date(numeric_system::alternative); + case 'n': { + const char newline[] = "\n"; + handler.on_text(newline, newline + 1); break; - case 'X': - handler.on_loc_time(numeric_system::alternative); - break; - default: - throw format_error("invalid format"); } - break; - } - case 'O': - if (ptr == end) - throw format_error("invalid format"); - c = *ptr++; - switch (c) { + case 't': { + const char tab[] = "\t"; + handler.on_text(tab, tab + 1); + break; + } + // Day of the week: + case 'a': + handler.on_abbr_weekday(); + break; + case 'A': + handler.on_full_weekday(); + break; case 'w': - handler.on_dec0_weekday(numeric_system::alternative); + handler.on_dec0_weekday(numeric_system::standard); break; case 'u': - handler.on_dec1_weekday(numeric_system::alternative); + handler.on_dec1_weekday(numeric_system::standard); break; + // Month: + case 'b': + handler.on_abbr_month(); + break; + case 'B': + handler.on_full_month(); + break; + // Hour, minute, second: case 'H': - handler.on_24_hour(numeric_system::alternative); + handler.on_24_hour(numeric_system::standard); break; case 'I': - handler.on_12_hour(numeric_system::alternative); + handler.on_12_hour(numeric_system::standard); break; case 'M': - handler.on_minute(numeric_system::alternative); + handler.on_minute(numeric_system::standard); break; case 'S': - handler.on_second(numeric_system::alternative); + handler.on_second(numeric_system::standard); + break; + // Other: + case 'c': + handler.on_datetime(numeric_system::standard); + break; + case 'x': + handler.on_loc_date(numeric_system::standard); + break; + case 'X': + handler.on_loc_time(numeric_system::standard); + break; + case 'D': + handler.on_us_date(); + break; + case 'F': + handler.on_iso_date(); + break; + case 'r': + handler.on_12_hour_time(); + break; + case 'R': + handler.on_24_hour_time(); + break; + case 'T': + handler.on_iso_time(); + break; + case 'p': + handler.on_am_pm(); + break; + case 'z': + handler.on_utc_offset(); + break; + case 'Z': + handler.on_tz_name(); + break; + // Alternative representation: + case 'E': { + if (ptr == end) throw format_error("invalid format"); + c = *ptr++; + switch (c) { + case 'c': + handler.on_datetime(numeric_system::alternative); + break; + case 'x': + handler.on_loc_date(numeric_system::alternative); + break; + case 'X': + handler.on_loc_time(numeric_system::alternative); + break; + default: + throw format_error("invalid format"); + } + break; + } + case 'O': + if (ptr == end) throw format_error("invalid format"); + c = *ptr++; + switch (c) { + case 'w': + handler.on_dec0_weekday(numeric_system::alternative); + break; + case 'u': + handler.on_dec1_weekday(numeric_system::alternative); + break; + case 'H': + handler.on_24_hour(numeric_system::alternative); + break; + case 'I': + handler.on_12_hour(numeric_system::alternative); + break; + case 'M': + handler.on_minute(numeric_system::alternative); + break; + case 'S': + handler.on_second(numeric_system::alternative); + break; + default: + throw format_error("invalid format"); + } break; default: throw format_error("invalid format"); - } - break; - default: - throw format_error("invalid format"); } begin = ptr; } - if (begin != ptr) - handler.on_text(begin, ptr); + if (begin != ptr) handler.on_text(begin, ptr); return ptr; } @@ -213,7 +209,8 @@ struct chrono_format_checker { template inline int to_int(Int value) { FMT_ASSERT(value >= (std::numeric_limits::min)() && - value <= (std::numeric_limits::max)(), "invalid value"); + value <= (std::numeric_limits::max)(), + "invalid value"); return static_cast(value); } @@ -227,7 +224,7 @@ struct chrono_formatter { typedef typename FormatContext::char_type char_type; explicit chrono_formatter(FormatContext &ctx, OutputIt o) - : context(ctx), out(o) {} + : context(ctx), out(o) {} int hour() const { return to_int((s.count() / 3600) % 24); } @@ -251,8 +248,7 @@ struct chrono_formatter { typedef typename int_traits::main_type main_type; main_type n = to_unsigned(value); int num_digits = internal::count_digits(n); - if (width > num_digits) - out = std::fill_n(out, width - num_digits, '0'); + if (width > num_digits) out = std::fill_n(out, width - num_digits, '0'); out = format_decimal(out, n, num_digits); } @@ -286,24 +282,21 @@ struct chrono_formatter { void on_tz_name() {} void on_24_hour(numeric_system ns) { - if (ns == numeric_system::standard) - return write(hour(), 2); + if (ns == numeric_system::standard) return write(hour(), 2); auto time = tm(); time.tm_hour = hour(); format_localized(time, "%OH"); } void on_12_hour(numeric_system ns) { - if (ns == numeric_system::standard) - return write(hour12(), 2); + if (ns == numeric_system::standard) return write(hour12(), 2); auto time = tm(); time.tm_hour = hour(); format_localized(time, "%OI"); } void on_minute(numeric_system ns) { - if (ns == numeric_system::standard) - return write(minute(), 2); + if (ns == numeric_system::standard) return write(minute(), 2); auto time = tm(); time.tm_min = minute(); format_localized(time, "%OM"); @@ -341,30 +334,84 @@ struct chrono_formatter { }; } // namespace internal -template FMT_CONSTEXPR const char *get_units() { +template +FMT_CONSTEXPR const char *get_units() { return FMT_NULL; } -template <> FMT_CONSTEXPR const char *get_units() { return "as"; } -template <> FMT_CONSTEXPR const char *get_units() { return "fs"; } -template <> FMT_CONSTEXPR const char *get_units() { return "ps"; } -template <> FMT_CONSTEXPR const char *get_units() { return "ns"; } -template <> FMT_CONSTEXPR const char *get_units() { return "µs"; } -template <> FMT_CONSTEXPR const char *get_units() { return "ms"; } -template <> FMT_CONSTEXPR const char *get_units() { return "cs"; } -template <> FMT_CONSTEXPR const char *get_units() { return "ds"; } -template <> FMT_CONSTEXPR const char *get_units>() { return "s"; } -template <> FMT_CONSTEXPR const char *get_units() { return "das"; } -template <> FMT_CONSTEXPR const char *get_units() { return "hs"; } -template <> FMT_CONSTEXPR const char *get_units() { return "ks"; } -template <> FMT_CONSTEXPR const char *get_units() { return "Ms"; } -template <> FMT_CONSTEXPR const char *get_units() { return "Gs"; } -template <> FMT_CONSTEXPR const char *get_units() { return "Ts"; } -template <> FMT_CONSTEXPR const char *get_units() { return "Ps"; } -template <> FMT_CONSTEXPR const char *get_units() { return "Es"; } -template <> FMT_CONSTEXPR const char *get_units>() { +template <> +FMT_CONSTEXPR const char *get_units() { + return "as"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "fs"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "ps"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "ns"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "µs"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "ms"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "cs"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "ds"; +} +template <> +FMT_CONSTEXPR const char *get_units>() { + return "s"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "das"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "hs"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "ks"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "Ms"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "Gs"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "Ts"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "Ps"; +} +template <> +FMT_CONSTEXPR const char *get_units() { + return "Es"; +} +template <> +FMT_CONSTEXPR const char *get_units>() { return "m"; } -template <> FMT_CONSTEXPR const char *get_units>() { +template <> +FMT_CONSTEXPR const char *get_units>() { return "h"; } @@ -415,13 +462,13 @@ struct formatter, Char> { if (begin == end) return begin; begin = internal::parse_width(begin, end, handler); end = parse_chrono_format(begin, end, internal::chrono_format_checker()); - format_str = basic_string_view(&*begin, internal::to_unsigned(end - begin)); + format_str = + basic_string_view(&*begin, internal::to_unsigned(end - begin)); return end; } template - auto format(const duration &d, FormatContext &ctx) - -> decltype(ctx.out()) { + auto format(const duration &d, FormatContext &ctx) -> decltype(ctx.out()) { auto begin = format_str.begin(), end = format_str.end(); memory_buffer buf; typedef output_range range; @@ -433,8 +480,8 @@ struct formatter, Char> { format_to(buf, "{}[{}]s", d.count(), Period::num); else format_to(buf, "{}[{}/{}]s", d.count(), Period::num, Period::den); - internal::handle_dynamic_spec( - spec.width_, width_ref, ctx); + internal::handle_dynamic_spec(spec.width_, + width_ref, ctx); } else { auto out = std::back_inserter(buf); internal::chrono_formatter f(ctx, out); diff --git a/src/cpp/include/deps/spdlog/fmt/bundled/color.h b/src/cpp/include/deps/spdlog/fmt/bundled/color.h old mode 100755 new mode 100644 index 5db861c93..4c24a3c30 --- a/src/cpp/include/deps/spdlog/fmt/bundled/color.h +++ b/src/cpp/include/deps/spdlog/fmt/bundled/color.h @@ -20,12 +20,12 @@ FMT_API void vprint_colored(color c, string_view format, format_args args); FMT_API void vprint_colored(color c, wstring_view format, wformat_args args); template inline void print_colored(color c, string_view format_str, - const Args & ... args) { + const Args&... args) { vprint_colored(c, format_str, make_format_args(args...)); } template inline void print_colored(color c, wstring_view format_str, - const Args & ... args) { + const Args&... args) { vprint_colored(c, format_str, make_format_args(args...)); } @@ -48,148 +48,148 @@ inline void vprint_colored(color c, wstring_view format, wformat_args args) { #else enum class color : uint32_t { - alice_blue = 0xF0F8FF, // rgb(240,248,255) - antique_white = 0xFAEBD7, // rgb(250,235,215) - aqua = 0x00FFFF, // rgb(0,255,255) - aquamarine = 0x7FFFD4, // rgb(127,255,212) - azure = 0xF0FFFF, // rgb(240,255,255) - beige = 0xF5F5DC, // rgb(245,245,220) - bisque = 0xFFE4C4, // rgb(255,228,196) - black = 0x000000, // rgb(0,0,0) - blanched_almond = 0xFFEBCD, // rgb(255,235,205) - blue = 0x0000FF, // rgb(0,0,255) - blue_violet = 0x8A2BE2, // rgb(138,43,226) - brown = 0xA52A2A, // rgb(165,42,42) - burly_wood = 0xDEB887, // rgb(222,184,135) - cadet_blue = 0x5F9EA0, // rgb(95,158,160) - chartreuse = 0x7FFF00, // rgb(127,255,0) - chocolate = 0xD2691E, // rgb(210,105,30) - coral = 0xFF7F50, // rgb(255,127,80) - cornflower_blue = 0x6495ED, // rgb(100,149,237) - cornsilk = 0xFFF8DC, // rgb(255,248,220) - crimson = 0xDC143C, // rgb(220,20,60) - cyan = 0x00FFFF, // rgb(0,255,255) - dark_blue = 0x00008B, // rgb(0,0,139) - dark_cyan = 0x008B8B, // rgb(0,139,139) - dark_golden_rod = 0xB8860B, // rgb(184,134,11) - dark_gray = 0xA9A9A9, // rgb(169,169,169) - dark_green = 0x006400, // rgb(0,100,0) - dark_khaki = 0xBDB76B, // rgb(189,183,107) - dark_magenta = 0x8B008B, // rgb(139,0,139) - dark_olive_green = 0x556B2F, // rgb(85,107,47) - dark_orange = 0xFF8C00, // rgb(255,140,0) - dark_orchid = 0x9932CC, // rgb(153,50,204) - dark_red = 0x8B0000, // rgb(139,0,0) - dark_salmon = 0xE9967A, // rgb(233,150,122) - dark_sea_green = 0x8FBC8F, // rgb(143,188,143) - dark_slate_blue = 0x483D8B, // rgb(72,61,139) - dark_slate_gray = 0x2F4F4F, // rgb(47,79,79) - dark_turquoise = 0x00CED1, // rgb(0,206,209) - dark_violet = 0x9400D3, // rgb(148,0,211) - deep_pink = 0xFF1493, // rgb(255,20,147) - deep_sky_blue = 0x00BFFF, // rgb(0,191,255) - dim_gray = 0x696969, // rgb(105,105,105) - dodger_blue = 0x1E90FF, // rgb(30,144,255) - fire_brick = 0xB22222, // rgb(178,34,34) - floral_white = 0xFFFAF0, // rgb(255,250,240) - forest_green = 0x228B22, // rgb(34,139,34) - fuchsia = 0xFF00FF, // rgb(255,0,255) - gainsboro = 0xDCDCDC, // rgb(220,220,220) - ghost_white = 0xF8F8FF, // rgb(248,248,255) - gold = 0xFFD700, // rgb(255,215,0) - golden_rod = 0xDAA520, // rgb(218,165,32) - gray = 0x808080, // rgb(128,128,128) - green = 0x008000, // rgb(0,128,0) - green_yellow = 0xADFF2F, // rgb(173,255,47) - honey_dew = 0xF0FFF0, // rgb(240,255,240) - hot_pink = 0xFF69B4, // rgb(255,105,180) - indian_red = 0xCD5C5C, // rgb(205,92,92) - indigo = 0x4B0082, // rgb(75,0,130) - ivory = 0xFFFFF0, // rgb(255,255,240) - khaki = 0xF0E68C, // rgb(240,230,140) - lavender = 0xE6E6FA, // rgb(230,230,250) - lavender_blush = 0xFFF0F5, // rgb(255,240,245) - lawn_green = 0x7CFC00, // rgb(124,252,0) - lemon_chiffon = 0xFFFACD, // rgb(255,250,205) - light_blue = 0xADD8E6, // rgb(173,216,230) - light_coral = 0xF08080, // rgb(240,128,128) - light_cyan = 0xE0FFFF, // rgb(224,255,255) - light_golden_rod_yellow = 0xFAFAD2, // rgb(250,250,210) - light_gray = 0xD3D3D3, // rgb(211,211,211) - light_green = 0x90EE90, // rgb(144,238,144) - light_pink = 0xFFB6C1, // rgb(255,182,193) - light_salmon = 0xFFA07A, // rgb(255,160,122) - light_sea_green = 0x20B2AA, // rgb(32,178,170) - light_sky_blue = 0x87CEFA, // rgb(135,206,250) - light_slate_gray = 0x778899, // rgb(119,136,153) - light_steel_blue = 0xB0C4DE, // rgb(176,196,222) - light_yellow = 0xFFFFE0, // rgb(255,255,224) - lime = 0x00FF00, // rgb(0,255,0) - lime_green = 0x32CD32, // rgb(50,205,50) - linen = 0xFAF0E6, // rgb(250,240,230) - magenta = 0xFF00FF, // rgb(255,0,255) - maroon = 0x800000, // rgb(128,0,0) - medium_aquamarine = 0x66CDAA, // rgb(102,205,170) - medium_blue = 0x0000CD, // rgb(0,0,205) - medium_orchid = 0xBA55D3, // rgb(186,85,211) - medium_purple = 0x9370DB, // rgb(147,112,219) - medium_sea_green = 0x3CB371, // rgb(60,179,113) - medium_slate_blue = 0x7B68EE, // rgb(123,104,238) - medium_spring_green = 0x00FA9A, // rgb(0,250,154) - medium_turquoise = 0x48D1CC, // rgb(72,209,204) - medium_violet_red = 0xC71585, // rgb(199,21,133) - midnight_blue = 0x191970, // rgb(25,25,112) - mint_cream = 0xF5FFFA, // rgb(245,255,250) - misty_rose = 0xFFE4E1, // rgb(255,228,225) - moccasin = 0xFFE4B5, // rgb(255,228,181) - navajo_white = 0xFFDEAD, // rgb(255,222,173) - navy = 0x000080, // rgb(0,0,128) - old_lace = 0xFDF5E6, // rgb(253,245,230) - olive = 0x808000, // rgb(128,128,0) - olive_drab = 0x6B8E23, // rgb(107,142,35) - orange = 0xFFA500, // rgb(255,165,0) - orange_red = 0xFF4500, // rgb(255,69,0) - orchid = 0xDA70D6, // rgb(218,112,214) - pale_golden_rod = 0xEEE8AA, // rgb(238,232,170) - pale_green = 0x98FB98, // rgb(152,251,152) - pale_turquoise = 0xAFEEEE, // rgb(175,238,238) - pale_violet_red = 0xDB7093, // rgb(219,112,147) - papaya_whip = 0xFFEFD5, // rgb(255,239,213) - peach_puff = 0xFFDAB9, // rgb(255,218,185) - peru = 0xCD853F, // rgb(205,133,63) - pink = 0xFFC0CB, // rgb(255,192,203) - plum = 0xDDA0DD, // rgb(221,160,221) - powder_blue = 0xB0E0E6, // rgb(176,224,230) - purple = 0x800080, // rgb(128,0,128) - rebecca_purple = 0x663399, // rgb(102,51,153) - red = 0xFF0000, // rgb(255,0,0) - rosy_brown = 0xBC8F8F, // rgb(188,143,143) - royal_blue = 0x4169E1, // rgb(65,105,225) - saddle_brown = 0x8B4513, // rgb(139,69,19) - salmon = 0xFA8072, // rgb(250,128,114) - sandy_brown = 0xF4A460, // rgb(244,164,96) - sea_green = 0x2E8B57, // rgb(46,139,87) - sea_shell = 0xFFF5EE, // rgb(255,245,238) - sienna = 0xA0522D, // rgb(160,82,45) - silver = 0xC0C0C0, // rgb(192,192,192) - sky_blue = 0x87CEEB, // rgb(135,206,235) - slate_blue = 0x6A5ACD, // rgb(106,90,205) - slate_gray = 0x708090, // rgb(112,128,144) - snow = 0xFFFAFA, // rgb(255,250,250) - spring_green = 0x00FF7F, // rgb(0,255,127) - steel_blue = 0x4682B4, // rgb(70,130,180) - tan = 0xD2B48C, // rgb(210,180,140) - teal = 0x008080, // rgb(0,128,128) - thistle = 0xD8BFD8, // rgb(216,191,216) - tomato = 0xFF6347, // rgb(255,99,71) - turquoise = 0x40E0D0, // rgb(64,224,208) - violet = 0xEE82EE, // rgb(238,130,238) - wheat = 0xF5DEB3, // rgb(245,222,179) - white = 0xFFFFFF, // rgb(255,255,255) - white_smoke = 0xF5F5F5, // rgb(245,245,245) - yellow = 0xFFFF00, // rgb(255,255,0) - yellow_green = 0x9ACD32 // rgb(154,205,50) -}; // enum class color + alice_blue = 0xF0F8FF, // rgb(240,248,255) + antique_white = 0xFAEBD7, // rgb(250,235,215) + aqua = 0x00FFFF, // rgb(0,255,255) + aquamarine = 0x7FFFD4, // rgb(127,255,212) + azure = 0xF0FFFF, // rgb(240,255,255) + beige = 0xF5F5DC, // rgb(245,245,220) + bisque = 0xFFE4C4, // rgb(255,228,196) + black = 0x000000, // rgb(0,0,0) + blanched_almond = 0xFFEBCD, // rgb(255,235,205) + blue = 0x0000FF, // rgb(0,0,255) + blue_violet = 0x8A2BE2, // rgb(138,43,226) + brown = 0xA52A2A, // rgb(165,42,42) + burly_wood = 0xDEB887, // rgb(222,184,135) + cadet_blue = 0x5F9EA0, // rgb(95,158,160) + chartreuse = 0x7FFF00, // rgb(127,255,0) + chocolate = 0xD2691E, // rgb(210,105,30) + coral = 0xFF7F50, // rgb(255,127,80) + cornflower_blue = 0x6495ED, // rgb(100,149,237) + cornsilk = 0xFFF8DC, // rgb(255,248,220) + crimson = 0xDC143C, // rgb(220,20,60) + cyan = 0x00FFFF, // rgb(0,255,255) + dark_blue = 0x00008B, // rgb(0,0,139) + dark_cyan = 0x008B8B, // rgb(0,139,139) + dark_golden_rod = 0xB8860B, // rgb(184,134,11) + dark_gray = 0xA9A9A9, // rgb(169,169,169) + dark_green = 0x006400, // rgb(0,100,0) + dark_khaki = 0xBDB76B, // rgb(189,183,107) + dark_magenta = 0x8B008B, // rgb(139,0,139) + dark_olive_green = 0x556B2F, // rgb(85,107,47) + dark_orange = 0xFF8C00, // rgb(255,140,0) + dark_orchid = 0x9932CC, // rgb(153,50,204) + dark_red = 0x8B0000, // rgb(139,0,0) + dark_salmon = 0xE9967A, // rgb(233,150,122) + dark_sea_green = 0x8FBC8F, // rgb(143,188,143) + dark_slate_blue = 0x483D8B, // rgb(72,61,139) + dark_slate_gray = 0x2F4F4F, // rgb(47,79,79) + dark_turquoise = 0x00CED1, // rgb(0,206,209) + dark_violet = 0x9400D3, // rgb(148,0,211) + deep_pink = 0xFF1493, // rgb(255,20,147) + deep_sky_blue = 0x00BFFF, // rgb(0,191,255) + dim_gray = 0x696969, // rgb(105,105,105) + dodger_blue = 0x1E90FF, // rgb(30,144,255) + fire_brick = 0xB22222, // rgb(178,34,34) + floral_white = 0xFFFAF0, // rgb(255,250,240) + forest_green = 0x228B22, // rgb(34,139,34) + fuchsia = 0xFF00FF, // rgb(255,0,255) + gainsboro = 0xDCDCDC, // rgb(220,220,220) + ghost_white = 0xF8F8FF, // rgb(248,248,255) + gold = 0xFFD700, // rgb(255,215,0) + golden_rod = 0xDAA520, // rgb(218,165,32) + gray = 0x808080, // rgb(128,128,128) + green = 0x008000, // rgb(0,128,0) + green_yellow = 0xADFF2F, // rgb(173,255,47) + honey_dew = 0xF0FFF0, // rgb(240,255,240) + hot_pink = 0xFF69B4, // rgb(255,105,180) + indian_red = 0xCD5C5C, // rgb(205,92,92) + indigo = 0x4B0082, // rgb(75,0,130) + ivory = 0xFFFFF0, // rgb(255,255,240) + khaki = 0xF0E68C, // rgb(240,230,140) + lavender = 0xE6E6FA, // rgb(230,230,250) + lavender_blush = 0xFFF0F5, // rgb(255,240,245) + lawn_green = 0x7CFC00, // rgb(124,252,0) + lemon_chiffon = 0xFFFACD, // rgb(255,250,205) + light_blue = 0xADD8E6, // rgb(173,216,230) + light_coral = 0xF08080, // rgb(240,128,128) + light_cyan = 0xE0FFFF, // rgb(224,255,255) + light_golden_rod_yellow = 0xFAFAD2, // rgb(250,250,210) + light_gray = 0xD3D3D3, // rgb(211,211,211) + light_green = 0x90EE90, // rgb(144,238,144) + light_pink = 0xFFB6C1, // rgb(255,182,193) + light_salmon = 0xFFA07A, // rgb(255,160,122) + light_sea_green = 0x20B2AA, // rgb(32,178,170) + light_sky_blue = 0x87CEFA, // rgb(135,206,250) + light_slate_gray = 0x778899, // rgb(119,136,153) + light_steel_blue = 0xB0C4DE, // rgb(176,196,222) + light_yellow = 0xFFFFE0, // rgb(255,255,224) + lime = 0x00FF00, // rgb(0,255,0) + lime_green = 0x32CD32, // rgb(50,205,50) + linen = 0xFAF0E6, // rgb(250,240,230) + magenta = 0xFF00FF, // rgb(255,0,255) + maroon = 0x800000, // rgb(128,0,0) + medium_aquamarine = 0x66CDAA, // rgb(102,205,170) + medium_blue = 0x0000CD, // rgb(0,0,205) + medium_orchid = 0xBA55D3, // rgb(186,85,211) + medium_purple = 0x9370DB, // rgb(147,112,219) + medium_sea_green = 0x3CB371, // rgb(60,179,113) + medium_slate_blue = 0x7B68EE, // rgb(123,104,238) + medium_spring_green = 0x00FA9A, // rgb(0,250,154) + medium_turquoise = 0x48D1CC, // rgb(72,209,204) + medium_violet_red = 0xC71585, // rgb(199,21,133) + midnight_blue = 0x191970, // rgb(25,25,112) + mint_cream = 0xF5FFFA, // rgb(245,255,250) + misty_rose = 0xFFE4E1, // rgb(255,228,225) + moccasin = 0xFFE4B5, // rgb(255,228,181) + navajo_white = 0xFFDEAD, // rgb(255,222,173) + navy = 0x000080, // rgb(0,0,128) + old_lace = 0xFDF5E6, // rgb(253,245,230) + olive = 0x808000, // rgb(128,128,0) + olive_drab = 0x6B8E23, // rgb(107,142,35) + orange = 0xFFA500, // rgb(255,165,0) + orange_red = 0xFF4500, // rgb(255,69,0) + orchid = 0xDA70D6, // rgb(218,112,214) + pale_golden_rod = 0xEEE8AA, // rgb(238,232,170) + pale_green = 0x98FB98, // rgb(152,251,152) + pale_turquoise = 0xAFEEEE, // rgb(175,238,238) + pale_violet_red = 0xDB7093, // rgb(219,112,147) + papaya_whip = 0xFFEFD5, // rgb(255,239,213) + peach_puff = 0xFFDAB9, // rgb(255,218,185) + peru = 0xCD853F, // rgb(205,133,63) + pink = 0xFFC0CB, // rgb(255,192,203) + plum = 0xDDA0DD, // rgb(221,160,221) + powder_blue = 0xB0E0E6, // rgb(176,224,230) + purple = 0x800080, // rgb(128,0,128) + rebecca_purple = 0x663399, // rgb(102,51,153) + red = 0xFF0000, // rgb(255,0,0) + rosy_brown = 0xBC8F8F, // rgb(188,143,143) + royal_blue = 0x4169E1, // rgb(65,105,225) + saddle_brown = 0x8B4513, // rgb(139,69,19) + salmon = 0xFA8072, // rgb(250,128,114) + sandy_brown = 0xF4A460, // rgb(244,164,96) + sea_green = 0x2E8B57, // rgb(46,139,87) + sea_shell = 0xFFF5EE, // rgb(255,245,238) + sienna = 0xA0522D, // rgb(160,82,45) + silver = 0xC0C0C0, // rgb(192,192,192) + sky_blue = 0x87CEEB, // rgb(135,206,235) + slate_blue = 0x6A5ACD, // rgb(106,90,205) + slate_gray = 0x708090, // rgb(112,128,144) + snow = 0xFFFAFA, // rgb(255,250,250) + spring_green = 0x00FF7F, // rgb(0,255,127) + steel_blue = 0x4682B4, // rgb(70,130,180) + tan = 0xD2B48C, // rgb(210,180,140) + teal = 0x008080, // rgb(0,128,128) + thistle = 0xD8BFD8, // rgb(216,191,216) + tomato = 0xFF6347, // rgb(255,99,71) + turquoise = 0x40E0D0, // rgb(64,224,208) + violet = 0xEE82EE, // rgb(238,130,238) + wheat = 0xF5DEB3, // rgb(245,222,179) + white = 0xFFFFFF, // rgb(255,255,255) + white_smoke = 0xF5F5F5, // rgb(245,245,245) + yellow = 0xFFFF00, // rgb(255,255,0) + yellow_green = 0x9ACD32 // rgb(154,205,50) +}; // enum class color enum class terminal_color : uint8_t { black = 30, @@ -223,12 +223,13 @@ enum class emphasis : uint8_t { struct rgb { FMT_CONSTEXPR_DECL rgb() : r(0), g(0), b(0) {} FMT_CONSTEXPR_DECL rgb(uint8_t r_, uint8_t g_, uint8_t b_) - : r(r_), g(g_), b(b_) {} + : r(r_), g(g_), b(b_) {} FMT_CONSTEXPR_DECL rgb(uint32_t hex) - : r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b((hex) & 0xFF) {} + : r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b((hex)&0xFF) {} FMT_CONSTEXPR_DECL rgb(color hex) - : r((uint32_t(hex) >> 16) & 0xFF), g((uint32_t(hex) >> 8) & 0xFF), - b(uint32_t(hex) & 0xFF) {} + : r((uint32_t(hex) >> 16) & 0xFF), + g((uint32_t(hex) >> 8) & 0xFF), + b(uint32_t(hex) & 0xFF) {} uint8_t r; uint8_t g; uint8_t b; @@ -238,19 +239,17 @@ namespace internal { // color is a struct of either a rgb color or a terminal color. struct color_type { - FMT_CONSTEXPR color_type() FMT_NOEXCEPT - : is_rgb(), value{} {} - FMT_CONSTEXPR color_type(color rgb_color) FMT_NOEXCEPT - : is_rgb(true), value{} { + FMT_CONSTEXPR color_type() FMT_NOEXCEPT : is_rgb(), value{} {} + FMT_CONSTEXPR color_type(color rgb_color) FMT_NOEXCEPT : is_rgb(true), + value{} { value.rgb_color = static_cast(rgb_color); } - FMT_CONSTEXPR color_type(rgb rgb_color) FMT_NOEXCEPT - : is_rgb(true), value{} { - value.rgb_color = (static_cast(rgb_color.r) << 16) - | (static_cast(rgb_color.g) << 8) | rgb_color.b; + FMT_CONSTEXPR color_type(rgb rgb_color) FMT_NOEXCEPT : is_rgb(true), value{} { + value.rgb_color = (static_cast(rgb_color.r) << 16) | + (static_cast(rgb_color.g) << 8) | rgb_color.b; } - FMT_CONSTEXPR color_type(terminal_color term_color) FMT_NOEXCEPT - : is_rgb(), value{} { + FMT_CONSTEXPR color_type(terminal_color term_color) FMT_NOEXCEPT : is_rgb(), + value{} { value.term_color = static_cast(term_color); } bool is_rgb; @@ -259,13 +258,15 @@ struct color_type { uint32_t rgb_color; } value; }; -} // namespace internal +} // namespace internal // Experimental text formatting support. class text_style { public: FMT_CONSTEXPR text_style(emphasis em = emphasis()) FMT_NOEXCEPT - : set_foreground_color(), set_background_color(), ems(em) {} + : set_foreground_color(), + set_background_color(), + ems(em) {} FMT_CONSTEXPR text_style &operator|=(const text_style &rhs) { if (!set_foreground_color) { @@ -291,8 +292,8 @@ class text_style { return *this; } - friend FMT_CONSTEXPR - text_style operator|(text_style lhs, const text_style &rhs) { + friend FMT_CONSTEXPR text_style operator|(text_style lhs, + const text_style &rhs) { return lhs |= rhs; } @@ -320,8 +321,8 @@ class text_style { return *this; } - friend FMT_CONSTEXPR - text_style operator&(text_style lhs, const text_style &rhs) { + friend FMT_CONSTEXPR text_style operator&(text_style lhs, + const text_style &rhs) { return lhs &= rhs; } @@ -347,20 +348,20 @@ class text_style { return ems; } -private: - FMT_CONSTEXPR text_style(bool is_foreground, - internal::color_type text_color) FMT_NOEXCEPT - : set_foreground_color(), - set_background_color(), - ems() { - if (is_foreground) { - foreground_color = text_color; - set_foreground_color = true; - } else { - background_color = text_color; - set_background_color = true; - } - } + private: + FMT_CONSTEXPR text_style(bool is_foreground, + internal::color_type text_color) FMT_NOEXCEPT + : set_foreground_color(), + set_background_color(), + ems() { + if (is_foreground) { + foreground_color = text_color; + set_foreground_color = true; + } else { + background_color = text_color; + set_background_color = true; + } + } friend FMT_CONSTEXPR_DECL text_style fg(internal::color_type foreground) FMT_NOEXCEPT; @@ -391,7 +392,7 @@ namespace internal { template struct ansi_color_escape { FMT_CONSTEXPR ansi_color_escape(internal::color_type text_color, - const char * esc) FMT_NOEXCEPT { + const char *esc) FMT_NOEXCEPT { // If we have a terminal color, we need to output another escape code // sequence. if (!text_color.is_rgb) { @@ -399,8 +400,7 @@ struct ansi_color_escape { uint32_t value = text_color.value.term_color; // Background ASCII codes are the same as the foreground ones but with // 10 more. - if (is_background) - value += 10u; + if (is_background) value += 10u; std::size_t index = 0; buffer[index++] = static_cast('\x1b'); @@ -422,7 +422,7 @@ struct ansi_color_escape { buffer[i] = static_cast(esc[i]); } rgb color(text_color.value.rgb_color); - to_esc(color.r, buffer + 7, ';'); + to_esc(color.r, buffer + 7, ';'); to_esc(color.g, buffer + 11, ';'); to_esc(color.b, buffer + 15, 'm'); buffer[19] = static_cast(0); @@ -430,19 +430,15 @@ struct ansi_color_escape { FMT_CONSTEXPR ansi_color_escape(emphasis em) FMT_NOEXCEPT { uint8_t em_codes[4] = {}; uint8_t em_bits = static_cast(em); - if (em_bits & static_cast(emphasis::bold)) - em_codes[0] = 1; - if (em_bits & static_cast(emphasis::italic)) - em_codes[1] = 3; - if (em_bits & static_cast(emphasis::underline)) - em_codes[2] = 4; + if (em_bits & static_cast(emphasis::bold)) em_codes[0] = 1; + if (em_bits & static_cast(emphasis::italic)) em_codes[1] = 3; + if (em_bits & static_cast(emphasis::underline)) em_codes[2] = 4; if (em_bits & static_cast(emphasis::strikethrough)) em_codes[3] = 9; std::size_t index = 0; for (int i = 0; i < 4; ++i) { - if (!em_codes[i]) - continue; + if (!em_codes[i]) continue; buffer[index++] = static_cast('\x1b'); buffer[index++] = static_cast('['); buffer[index++] = static_cast('0' + em_codes[i]); @@ -452,7 +448,7 @@ struct ansi_color_escape { } FMT_CONSTEXPR operator const Char *() const FMT_NOEXCEPT { return buffer; } -private: + private: Char buffer[7u + 3u * 4u + 1u]; static FMT_CONSTEXPR void to_esc(uint8_t c, Char *out, @@ -465,20 +461,19 @@ private: }; template -FMT_CONSTEXPR ansi_color_escape -make_foreground_color(internal::color_type foreground) FMT_NOEXCEPT { +FMT_CONSTEXPR ansi_color_escape make_foreground_color( + internal::color_type foreground) FMT_NOEXCEPT { return ansi_color_escape(foreground, internal::data::FOREGROUND_COLOR); } template -FMT_CONSTEXPR ansi_color_escape -make_background_color(internal::color_type background) FMT_NOEXCEPT { +FMT_CONSTEXPR ansi_color_escape make_background_color( + internal::color_type background) FMT_NOEXCEPT { return ansi_color_escape(background, internal::data::BACKGROUND_COLOR); } template -FMT_CONSTEXPR ansi_color_escape -make_emphasis(emphasis em) FMT_NOEXCEPT { +FMT_CONSTEXPR ansi_color_escape make_emphasis(emphasis em) FMT_NOEXCEPT { return ansi_color_escape(em); } @@ -510,22 +505,20 @@ template <> struct is_string : std::false_type {}; template <> struct is_string : std::false_type {}; -} // namespace internal +} // namespace internal -template < - typename S, typename Char = typename internal::char_t::type> +template ::type> void vprint(std::FILE *f, const text_style &ts, const S &format, basic_format_args::type> args) { bool has_style = false; if (ts.has_emphasis()) { has_style = true; - internal::fputs( - internal::make_emphasis(ts.get_emphasis()), f); + internal::fputs(internal::make_emphasis(ts.get_emphasis()), f); } if (ts.has_foreground()) { has_style = true; internal::fputs( - internal::make_foreground_color(ts.get_foreground()), f); + internal::make_foreground_color(ts.get_foreground()), f); } if (ts.has_background()) { has_style = true; @@ -565,8 +558,7 @@ typename std::enable_if::value>::type print( */ template typename std::enable_if::value>::type print( - const text_style &ts, const String &format_str, - const Args &... args) { + const text_style &ts, const String &format_str, const Args &... args) { return print(stdout, ts, format_str, args...); } diff --git a/src/cpp/include/deps/spdlog/fmt/bundled/core.h b/src/cpp/include/deps/spdlog/fmt/bundled/core.h old mode 100755 new mode 100644 index 50b793515..4c1e16983 --- a/src/cpp/include/deps/spdlog/fmt/bundled/core.h +++ b/src/cpp/include/deps/spdlog/fmt/bundled/core.h @@ -19,171 +19,178 @@ #define FMT_VERSION 50300 #ifdef __has_feature -# define FMT_HAS_FEATURE(x) __has_feature(x) +#define FMT_HAS_FEATURE(x) __has_feature(x) #else -# define FMT_HAS_FEATURE(x) 0 +#define FMT_HAS_FEATURE(x) 0 #endif #if defined(__has_include) && !defined(__INTELLISENSE__) && \ !(defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1600) -# define FMT_HAS_INCLUDE(x) __has_include(x) +#define FMT_HAS_INCLUDE(x) __has_include(x) #else -# define FMT_HAS_INCLUDE(x) 0 +#define FMT_HAS_INCLUDE(x) 0 #endif #ifdef __has_cpp_attribute -# define FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +#define FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) #else -# define FMT_HAS_CPP_ATTRIBUTE(x) 0 +#define FMT_HAS_CPP_ATTRIBUTE(x) 0 #endif #if defined(__GNUC__) && !defined(__clang__) -# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) +#define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) #else -# define FMT_GCC_VERSION 0 +#define FMT_GCC_VERSION 0 #endif #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) -# define FMT_HAS_GXX_CXX11 FMT_GCC_VERSION +#define FMT_HAS_GXX_CXX11 FMT_GCC_VERSION #else -# define FMT_HAS_GXX_CXX11 0 +#define FMT_HAS_GXX_CXX11 0 #endif #ifdef _MSC_VER -# define FMT_MSC_VER _MSC_VER +#define FMT_MSC_VER _MSC_VER #else -# define FMT_MSC_VER 0 +#define FMT_MSC_VER 0 #endif // Check if relaxed C++14 constexpr is supported. // GCC doesn't allow throw in constexpr until version 6 (bug 67371). #ifndef FMT_USE_CONSTEXPR -# define FMT_USE_CONSTEXPR \ +#define FMT_USE_CONSTEXPR \ (FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VER >= 1910 || \ (FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) #endif #if FMT_USE_CONSTEXPR -# define FMT_CONSTEXPR constexpr -# define FMT_CONSTEXPR_DECL constexpr +#define FMT_CONSTEXPR constexpr +#define FMT_CONSTEXPR_DECL constexpr #else -# define FMT_CONSTEXPR inline -# define FMT_CONSTEXPR_DECL +#define FMT_CONSTEXPR inline +#define FMT_CONSTEXPR_DECL #endif #ifndef FMT_USE_CONSTEXPR11 -# define FMT_USE_CONSTEXPR11 \ - (FMT_USE_CONSTEXPR || FMT_GCC_VERSION >= 406 || FMT_MSC_VER >= 1900) +#define FMT_USE_CONSTEXPR11 \ + (FMT_USE_CONSTEXPR || FMT_GCC_VERSION >= 406 || FMT_MSC_VER >= 1900) #endif #if FMT_USE_CONSTEXPR11 -# define FMT_CONSTEXPR11 constexpr +#define FMT_CONSTEXPR11 constexpr #else -# define FMT_CONSTEXPR11 +#define FMT_CONSTEXPR11 #endif #ifndef FMT_OVERRIDE -# if FMT_HAS_FEATURE(cxx_override) || \ - (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900 -# define FMT_OVERRIDE override -# else -# define FMT_OVERRIDE -# endif +#if FMT_HAS_FEATURE(cxx_override) || \ + (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900 +#define FMT_OVERRIDE override +#else +#define FMT_OVERRIDE +#endif #endif -#if FMT_HAS_FEATURE(cxx_explicit_conversions) || \ - FMT_GCC_VERSION >= 405 || FMT_MSC_VER >= 1800 -# define FMT_USE_EXPLICIT 1 -# define FMT_EXPLICIT explicit +#if FMT_HAS_FEATURE(cxx_explicit_conversions) || FMT_GCC_VERSION >= 405 || \ + FMT_MSC_VER >= 1800 +#define FMT_USE_EXPLICIT 1 +#define FMT_EXPLICIT explicit #else -# define FMT_USE_EXPLICIT 0 -# define FMT_EXPLICIT +#define FMT_USE_EXPLICIT 0 +#define FMT_EXPLICIT #endif #ifndef FMT_NULL -# if FMT_HAS_FEATURE(cxx_nullptr) || \ - (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1600 -# define FMT_NULL nullptr -# define FMT_USE_NULLPTR 1 -# else -# define FMT_NULL NULL -# endif +#if FMT_HAS_FEATURE(cxx_nullptr) || \ + (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1600 +#define FMT_NULL nullptr +#define FMT_USE_NULLPTR 1 +#else +#define FMT_NULL NULL +#endif #endif #ifndef FMT_USE_NULLPTR -# define FMT_USE_NULLPTR 0 +#define FMT_USE_NULLPTR 0 #endif // Check if exceptions are disabled. #ifndef FMT_EXCEPTIONS -# if (defined(__GNUC__) && !defined(__EXCEPTIONS)) || \ - FMT_MSC_VER && !_HAS_EXCEPTIONS -# define FMT_EXCEPTIONS 0 -# else -# define FMT_EXCEPTIONS 1 -# endif +#if (defined(__GNUC__) && !defined(__EXCEPTIONS)) || \ + FMT_MSC_VER && !_HAS_EXCEPTIONS +#define FMT_EXCEPTIONS 0 +#else +#define FMT_EXCEPTIONS 1 +#endif #endif // Define FMT_USE_NOEXCEPT to make fmt use noexcept (C++11 feature). #ifndef FMT_USE_NOEXCEPT -# define FMT_USE_NOEXCEPT 0 +#define FMT_USE_NOEXCEPT 0 #endif #if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \ (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900 -# define FMT_DETECTED_NOEXCEPT noexcept -# define FMT_HAS_CXX11_NOEXCEPT 1 +#define FMT_DETECTED_NOEXCEPT noexcept +#define FMT_HAS_CXX11_NOEXCEPT 1 #else -# define FMT_DETECTED_NOEXCEPT throw() -# define FMT_HAS_CXX11_NOEXCEPT 0 +#define FMT_DETECTED_NOEXCEPT throw() +#define FMT_HAS_CXX11_NOEXCEPT 0 #endif #ifndef FMT_NOEXCEPT -# if FMT_EXCEPTIONS || FMT_HAS_CXX11_NOEXCEPT -# define FMT_NOEXCEPT FMT_DETECTED_NOEXCEPT -# else -# define FMT_NOEXCEPT -# endif +#if FMT_EXCEPTIONS || FMT_HAS_CXX11_NOEXCEPT +#define FMT_NOEXCEPT FMT_DETECTED_NOEXCEPT +#else +#define FMT_NOEXCEPT +#endif #endif #ifndef FMT_BEGIN_NAMESPACE -# if FMT_HAS_FEATURE(cxx_inline_namespaces) || FMT_GCC_VERSION >= 404 || \ - FMT_MSC_VER >= 1900 -# define FMT_INLINE_NAMESPACE inline namespace -# define FMT_END_NAMESPACE }} -# else -# define FMT_INLINE_NAMESPACE namespace -# define FMT_END_NAMESPACE } using namespace v5; } -# endif -# define FMT_BEGIN_NAMESPACE namespace fmt { FMT_INLINE_NAMESPACE v5 { +#if FMT_HAS_FEATURE(cxx_inline_namespaces) || FMT_GCC_VERSION >= 404 || \ + FMT_MSC_VER >= 1900 +#define FMT_INLINE_NAMESPACE inline namespace +#define FMT_END_NAMESPACE \ + } \ + } +#else +#define FMT_INLINE_NAMESPACE namespace +#define FMT_END_NAMESPACE \ + } \ + using namespace v5; \ + } +#endif +#define FMT_BEGIN_NAMESPACE \ + namespace fmt { \ + FMT_INLINE_NAMESPACE v5 { #endif #if !defined(FMT_HEADER_ONLY) && defined(_WIN32) -# ifdef FMT_EXPORT -# define FMT_API __declspec(dllexport) -# elif defined(FMT_SHARED) -# define FMT_API __declspec(dllimport) -# endif +#ifdef FMT_EXPORT +#define FMT_API __declspec(dllexport) +#elif defined(FMT_SHARED) +#define FMT_API __declspec(dllimport) +#endif #endif #ifndef FMT_API -# define FMT_API +#define FMT_API #endif #ifndef FMT_ASSERT -# define FMT_ASSERT(condition, message) assert((condition) && message) +#define FMT_ASSERT(condition, message) assert((condition) && message) #endif // libc++ supports string_view in pre-c++17. -#if (FMT_HAS_INCLUDE() && \ - (__cplusplus > 201402L || defined(_LIBCPP_VERSION))) || \ +#if (FMT_HAS_INCLUDE() && \ + (__cplusplus > 201402L || defined(_LIBCPP_VERSION))) || \ (defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910) -# include -# define FMT_STRING_VIEW std::basic_string_view -#elif FMT_HAS_INCLUDE() && __cplusplus >= 201402L -# include -# define FMT_STRING_VIEW std::experimental::basic_string_view +#include +#define FMT_STRING_VIEW std::basic_string_view +#elif FMT_HAS_INCLUDE() && __cplusplus >= 201402L +#include +#define FMT_STRING_VIEW std::experimental::basic_string_view #endif // std::result_of is defined in in gcc 4.4. #if FMT_GCC_VERSION && FMT_GCC_VERSION <= 404 -# include +#include #endif FMT_BEGIN_NAMESPACE @@ -199,8 +206,8 @@ struct result_of; template struct result_of { // A workaround for gcc 4.4 that doesn't allow F to be a reference. - typedef typename std::result_of< - typename std::remove_reference::type(Args...)>::type type; + typedef typename std::result_of::type( + Args...)>::type type; }; // Casts nonnegative integer to unsigned. @@ -223,10 +230,12 @@ class basic_buffer { protected: // Don't initialize ptr_ since it is not accessed to save a few cycles. - basic_buffer(std::size_t sz) FMT_NOEXCEPT: size_(sz), capacity_(sz) {} + basic_buffer(std::size_t sz) FMT_NOEXCEPT : size_(sz), capacity_(sz) {} - basic_buffer(T *p = FMT_NULL, std::size_t sz = 0, std::size_t cap = 0) - FMT_NOEXCEPT: ptr_(p), size_(sz), capacity_(cap) {} + basic_buffer(T *p = FMT_NULL, std::size_t sz = 0, + std::size_t cap = 0) FMT_NOEXCEPT : ptr_(p), + size_(sz), + capacity_(cap) {} /** Sets the buffer data and capacity. */ void set(T *buf_data, std::size_t buf_capacity) FMT_NOEXCEPT { @@ -271,8 +280,7 @@ class basic_buffer { /** Reserves space to store at least *capacity* elements. */ void reserve(std::size_t new_capacity) { - if (new_capacity > capacity_) - grow(new_capacity); + if (new_capacity > capacity_) grow(new_capacity); } void push_back(const T &value) { @@ -305,14 +313,14 @@ class container_buffer : public basic_buffer { public: explicit container_buffer(Container &c) - : basic_buffer(c.size()), container_(c) {} + : basic_buffer(c.size()), container_(c) {} }; // Extracts a reference to the container from back_insert_iterator. template inline Container &get_container(std::back_insert_iterator it) { typedef std::back_insert_iterator bi_iterator; - struct accessor: bi_iterator { + struct accessor : bi_iterator { accessor(bi_iterator iter) : bi_iterator(iter) {} using bi_iterator::container; }; @@ -333,7 +341,7 @@ struct no_formatter_error : std::false_type {}; #if FMT_GCC_VERSION && FMT_GCC_VERSION < 405 template -struct is_constructible: std::false_type {}; +struct is_constructible : std::false_type {}; #else template struct is_constructible : std::is_constructible {}; @@ -360,7 +368,8 @@ class basic_string_view { /** Constructs a string reference object from a C string and a size. */ FMT_CONSTEXPR basic_string_view(const Char *s, size_t count) FMT_NOEXCEPT - : data_(s), size_(count) {} + : data_(s), + size_(count) {} /** \rst @@ -369,17 +378,18 @@ class basic_string_view { \endrst */ basic_string_view(const Char *s) - : data_(s), size_(std::char_traits::length(s)) {} + : data_(s), size_(std::char_traits::length(s)) {} /** Constructs a string reference from a ``std::basic_string`` object. */ template - FMT_CONSTEXPR basic_string_view( - const std::basic_string &s) FMT_NOEXCEPT - : data_(s.data()), size_(s.size()) {} + FMT_CONSTEXPR basic_string_view(const std::basic_string &s) + FMT_NOEXCEPT : data_(s.data()), + size_(s.size()) {} #ifdef FMT_STRING_VIEW FMT_CONSTEXPR basic_string_view(FMT_STRING_VIEW s) FMT_NOEXCEPT - : data_(s.data()), size_(s.size()) {} + : data_(s.data()), + size_(s.size()) {} #endif /** Returns a pointer to the string data. */ @@ -451,20 +461,26 @@ typedef basic_string_view wstring_view; \endrst */ template -inline basic_string_view - to_string_view(basic_string_view s) { return s; } +inline basic_string_view to_string_view(basic_string_view s) { + return s; +} template -inline basic_string_view - to_string_view(const std::basic_string &s) { return s; } +inline basic_string_view to_string_view( + const std::basic_string &s) { + return s; +} template -inline basic_string_view to_string_view(const Char *s) { return s; } +inline basic_string_view to_string_view(const Char *s) { + return s; +} #ifdef FMT_STRING_VIEW template -inline basic_string_view - to_string_view(FMT_STRING_VIEW s) { return s; } +inline basic_string_view to_string_view(FMT_STRING_VIEW s) { + return s; +} #endif // A base class for compile-time strings. It is defined in the fmt namespace to @@ -474,11 +490,12 @@ struct compile_string {}; template struct is_compile_string : std::is_base_of {}; -template < - typename S, - typename Enable = typename std::enable_if::value>::type> -FMT_CONSTEXPR basic_string_view - to_string_view(const S &s) { return s; } +template ::value>::type> +FMT_CONSTEXPR basic_string_view to_string_view( + const S &s) { + return s; +} template class basic_format_arg; @@ -489,9 +506,10 @@ class basic_format_args; // A formatter for objects of type T. template struct formatter { - static_assert(internal::no_formatter_error::value, - "don't know how to format the type, include fmt/ostream.h if it provides " - "an operator<< that should be used"); + static_assert( + internal::no_formatter_error::value, + "don't know how to format the type, include fmt/ostream.h if it provides " + "an operator<< that should be used"); // The following functions are not defined intentionally. template @@ -501,19 +519,25 @@ struct formatter { }; template -struct convert_to_int: std::integral_constant< - bool, !std::is_arithmetic::value && std::is_convertible::value> {}; +struct convert_to_int + : std::integral_constant::value && + std::is_convertible::value> {}; namespace internal { -struct dummy_string_view { typedef void char_type; }; +struct dummy_string_view { + typedef void char_type; +}; dummy_string_view to_string_view(...); using fmt::v5::to_string_view; // Specifies whether S is a string type convertible to fmt::basic_string_view. template -struct is_string : std::integral_constant()))>::value> {}; +struct is_string + : std::integral_constant< + bool, !std::is_same()))>::value> { +}; template struct char_t { @@ -528,13 +552,24 @@ template struct named_arg; enum type { - none_type, named_arg_type, + none_type, + named_arg_type, // Integer types should go first, - int_type, uint_type, long_long_type, ulong_long_type, bool_type, char_type, + int_type, + uint_type, + long_long_type, + ulong_long_type, + bool_type, + char_type, last_integer_type = char_type, // followed by floating-point types. - double_type, long_double_type, last_numeric_type = long_double_type, - cstring_type, string_type, pointer_type, custom_type + double_type, + long_double_type, + last_numeric_type = long_double_type, + cstring_type, + string_type, + pointer_type, + custom_type }; FMT_CONSTEXPR bool is_integral(type t) { @@ -609,7 +644,7 @@ class value { } const named_arg_base &as_named_arg() { - return *static_cast*>(pointer); + return *static_cast *>(pointer); } private: @@ -622,7 +657,7 @@ class value { typename Context::template formatter_type::type f; auto &&parse_ctx = ctx.parse_context(); parse_ctx.advance_to(f.parse(parse_ctx)); - ctx.advance_to(f.format(*static_cast(arg), ctx)); + ctx.advance_to(f.format(*static_cast(arg), ctx)); } }; @@ -639,15 +674,17 @@ struct init { template FMT_CONSTEXPR basic_format_arg make_arg(const T &value); -#define FMT_MAKE_VALUE(TAG, ArgType, ValueType) \ - template \ +#define FMT_MAKE_VALUE(TAG, ArgType, ValueType) \ + template \ FMT_CONSTEXPR init make_value(ArgType val) { \ - return static_cast(val); \ + return static_cast(val); \ } -#define FMT_MAKE_VALUE_SAME(TAG, Type) \ - template \ - FMT_CONSTEXPR init make_value(Type val) { return val; } +#define FMT_MAKE_VALUE_SAME(TAG, Type) \ + template \ + FMT_CONSTEXPR init make_value(Type val) { \ + return val; \ + } FMT_MAKE_VALUE(bool_type, bool, int) FMT_MAKE_VALUE(int_type, short, int) @@ -658,14 +695,14 @@ FMT_MAKE_VALUE_SAME(uint_type, unsigned) // To minimize the number of types we need to deal with, long is translated // either to int or to long long depending on its size. typedef std::conditional::type - long_type; -FMT_MAKE_VALUE( - (sizeof(long) == sizeof(int) ? int_type : long_long_type), long, long_type) -typedef std::conditional::type ulong_type; -FMT_MAKE_VALUE( - (sizeof(unsigned long) == sizeof(unsigned) ? uint_type : ulong_long_type), - unsigned long, ulong_type) + long_type; +FMT_MAKE_VALUE((sizeof(long) == sizeof(int) ? int_type : long_long_type), long, + long_type) +typedef std::conditional::type ulong_type; +FMT_MAKE_VALUE((sizeof(unsigned long) == sizeof(unsigned) ? uint_type + : ulong_long_type), + unsigned long, ulong_type) FMT_MAKE_VALUE_SAME(long_long_type, long long) FMT_MAKE_VALUE_SAME(ulong_long_type, unsigned long long) @@ -674,14 +711,20 @@ FMT_MAKE_VALUE(uint_type, unsigned char, unsigned) // This doesn't use FMT_MAKE_VALUE because of ambiguity in gcc 4.4. template -FMT_CONSTEXPR typename std::enable_if< - std::is_same::value, - init>::type make_value(Char val) { return val; } +FMT_CONSTEXPR + typename std::enable_if::value, + init>::type + make_value(Char val) { + return val; +} template -FMT_CONSTEXPR typename std::enable_if< - !std::is_same::value, - init>::type make_value(char val) { return val; } +FMT_CONSTEXPR + typename std::enable_if::value, + init>::type + make_value(char val) { + return val; +} FMT_MAKE_VALUE(double_type, float, double) FMT_MAKE_VALUE_SAME(double_type, double) @@ -689,26 +732,26 @@ FMT_MAKE_VALUE_SAME(long_double_type, long double) // Formatting of wide strings into a narrow buffer and multibyte strings // into a wide buffer is disallowed (https://github.com/fmtlib/fmt/pull/606). -FMT_MAKE_VALUE(cstring_type, typename C::char_type*, - const typename C::char_type*) -FMT_MAKE_VALUE(cstring_type, const typename C::char_type*, - const typename C::char_type*) +FMT_MAKE_VALUE(cstring_type, typename C::char_type *, + const typename C::char_type *) +FMT_MAKE_VALUE(cstring_type, const typename C::char_type *, + const typename C::char_type *) -FMT_MAKE_VALUE(cstring_type, signed char*, const signed char*) -FMT_MAKE_VALUE_SAME(cstring_type, const signed char*) -FMT_MAKE_VALUE(cstring_type, unsigned char*, const unsigned char*) -FMT_MAKE_VALUE_SAME(cstring_type, const unsigned char*) +FMT_MAKE_VALUE(cstring_type, signed char *, const signed char *) +FMT_MAKE_VALUE_SAME(cstring_type, const signed char *) +FMT_MAKE_VALUE(cstring_type, unsigned char *, const unsigned char *) +FMT_MAKE_VALUE_SAME(cstring_type, const unsigned char *) FMT_MAKE_VALUE_SAME(string_type, basic_string_view) FMT_MAKE_VALUE(string_type, typename basic_string_view::type, basic_string_view) -FMT_MAKE_VALUE(string_type, const std::basic_string&, +FMT_MAKE_VALUE(string_type, const std::basic_string &, basic_string_view) -FMT_MAKE_VALUE(pointer_type, void*, const void*) -FMT_MAKE_VALUE_SAME(pointer_type, const void*) +FMT_MAKE_VALUE(pointer_type, void *, const void *) +FMT_MAKE_VALUE_SAME(pointer_type, const void *) #if FMT_USE_NULLPTR -FMT_MAKE_VALUE(pointer_type, std::nullptr_t, const void*) +FMT_MAKE_VALUE(pointer_type, std::nullptr_t, const void *) #endif // Formatting of arbitrary pointers is disallowed. If you want to output a @@ -717,51 +760,58 @@ FMT_MAKE_VALUE(pointer_type, std::nullptr_t, const void*) // iostreams. template typename std::enable_if::value>::type - make_value(const T *) { +make_value(const T *) { static_assert(!sizeof(T), "formatting of non-void pointers is disallowed"); } template -inline typename std::enable_if< - std::is_enum::value && convert_to_int::value, - init>::type - make_value(const T &val) { return static_cast(val); } +inline + typename std::enable_if::value && + convert_to_int::value, + init>::type + make_value(const T &val) { + return static_cast(val); +} template inline typename std::enable_if< is_constructible, T>::value && - !internal::is_string::value, + !internal::is_string::value, init, string_type>>::type - make_value(const T &val) { return basic_string_view(val); } +make_value(const T &val) { + return basic_string_view(val); +} template inline typename std::enable_if< !convert_to_int::value && !std::is_same::value && - !std::is_convertible>::value && - !is_constructible, T>::value && - !internal::is_string::value, + !std::is_convertible>::value && + !is_constructible, T>::value && + !internal::is_string::value, // Implicit conversion to std::string is not handled here because it's // unsafe: https://github.com/fmtlib/fmt/issues/729 init>::type - make_value(const T &val) { return val; } +make_value(const T &val) { + return val; +} template -init - make_value(const named_arg &val) { +init make_value( + const named_arg &val) { basic_format_arg arg = make_arg(val.value); std::memcpy(val.data, &arg, sizeof(arg)); - return static_cast(&val); + return static_cast(&val); } template FMT_CONSTEXPR11 typename std::enable_if< - internal::is_string::value, - init, string_type>>::type - make_value(const S &val) { + internal::is_string::value, + init, string_type>>::type +make_value(const S &val) { // Handle adapted strings. - static_assert(std::is_same< - typename C::char_type, typename internal::char_t::type>::value, - "mismatch between char-types of context and argument"); + static_assert(std::is_same::type>::value, + "mismatch between char-types of context and argument"); return to_string_view(val); } @@ -782,12 +832,12 @@ class basic_format_arg { internal::type type_; template - friend FMT_CONSTEXPR basic_format_arg - internal::make_arg(const T &value); + friend FMT_CONSTEXPR basic_format_arg internal::make_arg( + const T &value); template friend FMT_CONSTEXPR typename internal::result_of::type - visit_format_arg(Visitor &&vis, const basic_format_arg &arg); + visit_format_arg(Visitor &&vis, const basic_format_arg &arg); friend class basic_format_args; friend class internal::arg_map; @@ -797,7 +847,7 @@ class basic_format_arg { public: class handle { public: - explicit handle(internal::custom_value custom): custom_(custom) {} + explicit handle(internal::custom_value custom) : custom_(custom) {} void format(Context &ctx) const { custom_.format(custom_.value, ctx); } @@ -827,48 +877,48 @@ struct monostate {}; \endrst */ template -FMT_CONSTEXPR typename internal::result_of::type - visit_format_arg(Visitor &&vis, const basic_format_arg &arg) { +FMT_CONSTEXPR typename internal::result_of::type visit_format_arg( + Visitor &&vis, const basic_format_arg &arg) { typedef typename Context::char_type char_type; switch (arg.type_) { - case internal::none_type: - break; - case internal::named_arg_type: - FMT_ASSERT(false, "invalid argument type"); - break; - case internal::int_type: - return vis(arg.value_.int_value); - case internal::uint_type: - return vis(arg.value_.uint_value); - case internal::long_long_type: - return vis(arg.value_.long_long_value); - case internal::ulong_long_type: - return vis(arg.value_.ulong_long_value); - case internal::bool_type: - return vis(arg.value_.int_value != 0); - case internal::char_type: - return vis(static_cast(arg.value_.int_value)); - case internal::double_type: - return vis(arg.value_.double_value); - case internal::long_double_type: - return vis(arg.value_.long_double_value); - case internal::cstring_type: - return vis(arg.value_.string.value); - case internal::string_type: - return vis(basic_string_view( - arg.value_.string.value, arg.value_.string.size)); - case internal::pointer_type: - return vis(arg.value_.pointer); - case internal::custom_type: - return vis(typename basic_format_arg::handle(arg.value_.custom)); + case internal::none_type: + break; + case internal::named_arg_type: + FMT_ASSERT(false, "invalid argument type"); + break; + case internal::int_type: + return vis(arg.value_.int_value); + case internal::uint_type: + return vis(arg.value_.uint_value); + case internal::long_long_type: + return vis(arg.value_.long_long_value); + case internal::ulong_long_type: + return vis(arg.value_.ulong_long_value); + case internal::bool_type: + return vis(arg.value_.int_value != 0); + case internal::char_type: + return vis(static_cast(arg.value_.int_value)); + case internal::double_type: + return vis(arg.value_.double_value); + case internal::long_double_type: + return vis(arg.value_.long_double_value); + case internal::cstring_type: + return vis(arg.value_.string.value); + case internal::string_type: + return vis(basic_string_view(arg.value_.string.value, + arg.value_.string.size)); + case internal::pointer_type: + return vis(arg.value_.pointer); + case internal::custom_type: + return vis(typename basic_format_arg::handle(arg.value_.custom)); } return vis(monostate()); } // DEPRECATED! template -FMT_CONSTEXPR typename internal::result_of::type - visit(Visitor &&vis, const basic_format_arg &arg) { +FMT_CONSTEXPR typename internal::result_of::type visit( + Visitor &&vis, const basic_format_arg &arg) { return visit_format_arg(std::forward(vis), arg); } @@ -884,9 +934,9 @@ class basic_parse_context : private ErrorHandler { typedef Char char_type; typedef typename basic_string_view::iterator iterator; - explicit FMT_CONSTEXPR basic_parse_context( - basic_string_view format_str, ErrorHandler eh = ErrorHandler()) - : ErrorHandler(eh), format_str_(format_str), next_arg_id_(0) {} + explicit FMT_CONSTEXPR basic_parse_context(basic_string_view format_str, + ErrorHandler eh = ErrorHandler()) + : ErrorHandler(eh), format_str_(format_str), next_arg_id_(0) {} // Returns an iterator to the beginning of the format string range being // parsed. @@ -956,13 +1006,12 @@ class arg_map { public: arg_map() : map_(FMT_NULL), size_(0) {} void init(const basic_format_args &args); - ~arg_map() { delete [] map_; } + ~arg_map() { delete[] map_; } basic_format_arg find(basic_string_view name) const { // The list is unsorted, so just return the first matching name. for (entry *it = map_, *end = map_ + size_; it != end; ++it) { - if (it->name == name) - return it->arg; + if (it->name == name) return it->arg; } return {}; } @@ -1002,26 +1051,25 @@ class context_base { context_base(OutputIt out, basic_string_view format_str, basic_format_args ctx_args, locale_ref loc = locale_ref()) - : parse_context_(format_str), out_(out), args_(ctx_args), loc_(loc) {} + : parse_context_(format_str), out_(out), args_(ctx_args), loc_(loc) {} // Returns the argument with specified index. format_arg do_get_arg(unsigned arg_id) { format_arg arg = args_.get(arg_id); - if (!arg) - parse_context_.on_error("argument index out of range"); + if (!arg) parse_context_.on_error("argument index out of range"); return arg; } // Checks if manual indexing is used and returns the argument with // specified index. format_arg get_arg(unsigned arg_id) { - return this->parse_context().check_arg_id(arg_id) ? - this->do_get_arg(arg_id) : format_arg(); + return this->parse_context().check_arg_id(arg_id) ? this->do_get_arg(arg_id) + : format_arg(); } public: basic_parse_context &parse_context() { return parse_context_; } - basic_format_args args() const { return args_; } // DEPRECATED! + basic_format_args args() const { return args_; } // DEPRECATED! basic_format_arg arg(unsigned id) const { return args_.get(id); } internal::error_handler error_handler() { @@ -1043,12 +1091,14 @@ class context_base { template struct get_type { typedef decltype(make_value( - declval::type&>())) value_type; + declval::type &>())) value_type; static const type value = value_type::type_tag; }; template -FMT_CONSTEXPR11 unsigned long long get_types() { return 0; } +FMT_CONSTEXPR11 unsigned long long get_types() { + return 0; +} template FMT_CONSTEXPR11 unsigned long long get_types() { @@ -1064,30 +1114,32 @@ FMT_CONSTEXPR basic_format_arg make_arg(const T &value) { } template -inline typename std::enable_if>::type - make_arg(const T &value) { +inline typename std::enable_if>::type make_arg( + const T &value) { return make_value(value); } template inline typename std::enable_if>::type - make_arg(const T &value) { +make_arg(const T &value) { return make_arg(value); } } // namespace internal // Formatting context. template -class basic_format_context : - public internal::context_base< - OutputIt, basic_format_context, Char> { +class basic_format_context + : public internal::context_base< + OutputIt, basic_format_context, Char> { public: /** The character type for the output. */ typedef Char char_type; // using formatter_type = formatter; template - struct formatter_type { typedef formatter type; }; + struct formatter_type { + typedef formatter type; + }; private: internal::arg_map map_; @@ -1109,7 +1161,7 @@ class basic_format_context : basic_format_context(OutputIt out, basic_string_view format_str, basic_format_args ctx_args, internal::locale_ref loc = internal::locale_ref()) - : base(out, format_str, ctx_args, loc) {} + : base(out, format_str, ctx_args, loc) {} format_arg next_arg() { return this->do_get_arg(this->parse_context().next_arg_id()); @@ -1124,7 +1176,8 @@ class basic_format_context : template struct buffer_context { typedef basic_format_context< - std::back_insert_iterator>, Char> type; + std::back_insert_iterator>, Char> + type; }; typedef buffer_context::type format_context; typedef buffer_context::type wformat_context; @@ -1136,7 +1189,7 @@ typedef buffer_context::type wformat_context; such as `~fmt::vformat`. \endrst */ -template +template class format_arg_store { private: static const size_t NUM_ARGS = sizeof...(Args); @@ -1144,20 +1197,19 @@ class format_arg_store { // Packed is a macro on MinGW so use IS_PACKED instead. static const bool IS_PACKED = NUM_ARGS < internal::max_packed_args; - typedef typename std::conditional, basic_format_arg>::type value_type; + typedef typename std::conditional, + basic_format_arg>::type value_type; // If the arguments are not packed, add one more element to mark the end. static const size_t DATA_SIZE = - NUM_ARGS + (IS_PACKED && NUM_ARGS != 0 ? 0 : 1); + NUM_ARGS + (IS_PACKED && NUM_ARGS != 0 ? 0 : 1); value_type data_[DATA_SIZE]; friend class basic_format_args; static FMT_CONSTEXPR11 unsigned long long get_types() { - return IS_PACKED ? - internal::get_types() : - internal::is_unpacked_bit | NUM_ARGS; + return IS_PACKED ? internal::get_types() + : internal::is_unpacked_bit | NUM_ARGS; } public: @@ -1171,18 +1223,18 @@ class format_arg_store { (FMT_MSC_VER && FMT_MSC_VER <= 1800) // Workaround array initialization issues in gcc <= 4.5 and MSVC <= 2013. format_arg_store(const Args &... args) { - value_type init[DATA_SIZE] = - {internal::make_arg(args)...}; + value_type init[DATA_SIZE] = { + internal::make_arg(args)...}; std::memcpy(data_, init, sizeof(init)); } #else format_arg_store(const Args &... args) - : data_{internal::make_arg(args)...} {} + : data_{internal::make_arg(args)...} {} #endif }; #if !FMT_USE_CONSTEXPR11 -template +template const unsigned long long format_arg_store::TYPES = get_types(); #endif @@ -1194,16 +1246,18 @@ const unsigned long long format_arg_store::TYPES = can be omitted in which case it defaults to `~fmt::context`. \endrst */ -template -inline format_arg_store - make_format_args(const Args &... args) { return {args...}; } +template +inline format_arg_store make_format_args( + const Args &... args) { + return {args...}; +} /** Formatting arguments. */ template class basic_format_args { public: typedef unsigned size_type; - typedef basic_format_arg format_arg; + typedef basic_format_arg format_arg; private: // To reduce compiled code size per formatting function call, types of first @@ -1223,8 +1277,8 @@ class basic_format_args { typename internal::type type(unsigned index) const { unsigned shift = index * 4; - return static_cast( - (types_ & (0xfull << shift)) >> shift); + return static_cast((types_ & (0xfull << shift)) >> + shift); } friend class internal::arg_map; @@ -1236,15 +1290,12 @@ class basic_format_args { format_arg arg; if (!is_packed()) { auto num_args = max_size(); - if (index < num_args) - arg = args_[index]; + if (index < num_args) arg = args_[index]; return arg; } - if (index > internal::max_packed_args) - return arg; + if (index > internal::max_packed_args) return arg; arg.type_ = type(index); - if (arg.type_ == internal::none_type) - return arg; + if (arg.type_ == internal::none_type) return arg; internal::value &val = arg.value_; val = values_[index]; return arg; @@ -1260,7 +1311,7 @@ class basic_format_args { */ template basic_format_args(const format_arg_store &store) - : types_(static_cast(store.TYPES)) { + : types_(static_cast(store.TYPES)) { set_data(store.data_); } @@ -1270,7 +1321,7 @@ class basic_format_args { \endrst */ basic_format_args(const format_arg *args, size_type count) - : types_(internal::is_unpacked_bit | count) { + : types_(internal::is_unpacked_bit | count) { set_data(args); } @@ -1285,38 +1336,38 @@ class basic_format_args { size_type max_size() const { unsigned long long max_packed = internal::max_packed_args; return static_cast( - is_packed() ? max_packed : types_ & ~internal::is_unpacked_bit); + is_packed() ? max_packed : types_ & ~internal::is_unpacked_bit); } }; /** An alias to ``basic_format_args``. */ // It is a separate type rather than a typedef to make symbols readable. struct format_args : basic_format_args { - template + template format_args(Args &&... arg) - : basic_format_args(std::forward(arg)...) {} + : basic_format_args(std::forward(arg)...) {} }; struct wformat_args : basic_format_args { - template + template wformat_args(Args &&... arg) - : basic_format_args(std::forward(arg)...) {} + : basic_format_args(std::forward(arg)...) {} }; #define FMT_ENABLE_IF_T(B, T) typename std::enable_if::type #ifndef FMT_USE_ALIAS_TEMPLATES -# define FMT_USE_ALIAS_TEMPLATES FMT_HAS_FEATURE(cxx_alias_templates) +#define FMT_USE_ALIAS_TEMPLATES FMT_HAS_FEATURE(cxx_alias_templates) #endif #if FMT_USE_ALIAS_TEMPLATES /** String's character type. */ template -using char_t = FMT_ENABLE_IF_T( - internal::is_string::value, typename internal::char_t::type); +using char_t = FMT_ENABLE_IF_T(internal::is_string::value, + typename internal::char_t::type); #define FMT_CHAR(S) fmt::char_t #else template -struct char_t : std::enable_if< - internal::is_string::value, typename internal::char_t::type> {}; +struct char_t : std::enable_if::value, + typename internal::char_t::type> {}; #define FMT_CHAR(S) typename char_t::type #endif @@ -1326,8 +1377,8 @@ struct named_arg_base { basic_string_view name; // Serialized value. - mutable char data[ - sizeof(basic_format_arg::type>)]; + mutable char + data[sizeof(basic_format_arg::type>)]; named_arg_base(basic_string_view nm) : name(nm) {} @@ -1344,23 +1395,23 @@ struct named_arg : named_arg_base { const T &value; named_arg(basic_string_view name, const T &val) - : named_arg_base(name), value(val) {} + : named_arg_base(name), value(val) {} }; template inline typename std::enable_if::value>::type - check_format_string(const S &) {} +check_format_string(const S &) {} template -typename std::enable_if::value>::type - check_format_string(S); +typename std::enable_if::value>::type check_format_string( + S); template -struct checked_args : format_arg_store< - typename buffer_context::type, Args...> { +struct checked_args + : format_arg_store::type, Args...> { typedef typename buffer_context::type context; - checked_args(const S &format_str, const Args &... args): - format_arg_store(args...) { + checked_args(const S &format_str, const Args &... args) + : format_arg_store(args...) { internal::check_format_string(format_str); } @@ -1369,14 +1420,14 @@ struct checked_args : format_arg_store< template std::basic_string vformat( - basic_string_view format_str, - basic_format_args::type> args); + basic_string_view format_str, + basic_format_args::type> args); template typename buffer_context::type::iterator vformat_to( - internal::basic_buffer &buf, basic_string_view format_str, - basic_format_args::type> args); -} + internal::basic_buffer &buf, basic_string_view format_str, + basic_format_args::type> args); +} // namespace internal /** \rst @@ -1402,33 +1453,31 @@ template void arg(S, internal::named_arg) = delete; template -struct is_contiguous: std::false_type {}; +struct is_contiguous : std::false_type {}; template -struct is_contiguous >: std::true_type {}; +struct is_contiguous> : std::true_type {}; template -struct is_contiguous >: std::true_type {}; +struct is_contiguous> : std::true_type {}; /** Formats a string and writes the output to ``out``. */ template -typename std::enable_if< - is_contiguous::value, std::back_insert_iterator>::type - vformat_to( - std::back_insert_iterator out, - const S &format_str, - basic_format_args::type> args) { +typename std::enable_if::value, + std::back_insert_iterator>::type +vformat_to(std::back_insert_iterator out, const S &format_str, + basic_format_args::type> args) { internal::container_buffer buf(internal::get_container(out)); internal::vformat_to(buf, to_string_view(format_str), args); return out; } template -inline typename std::enable_if< - is_contiguous::value && internal::is_string::value, - std::back_insert_iterator>::type - format_to(std::back_insert_iterator out, const S &format_str, - const Args &... args) { +inline typename std::enable_if::value && + internal::is_string::value, + std::back_insert_iterator>::type +format_to(std::back_insert_iterator out, const S &format_str, + const Args &... args) { internal::checked_args ca(format_str, args...); return vformat_to(out, to_string_view(format_str), *ca); } @@ -1451,11 +1500,11 @@ inline std::basic_string vformat( \endrst */ template -inline std::basic_string format( - const S &format_str, const Args &... args) { +inline std::basic_string format(const S &format_str, + const Args &... args) { return internal::vformat( - to_string_view(format_str), - *internal::checked_args(format_str, args...)); + to_string_view(format_str), + *internal::checked_args(format_str, args...)); } FMT_API void vprint(std::FILE *f, string_view format_str, format_args args); diff --git a/src/cpp/include/deps/spdlog/fmt/bundled/format-inl.h b/src/cpp/include/deps/spdlog/fmt/bundled/format-inl.h old mode 100755 new mode 100644 index 552c94303..05e4c010a --- a/src/cpp/include/deps/spdlog/fmt/bundled/format-inl.h +++ b/src/cpp/include/deps/spdlog/fmt/bundled/format-inl.h @@ -8,8 +8,6 @@ #ifndef FMT_FORMAT_INL_H_ #define FMT_FORMAT_INL_H_ -#include "format.h" - #include #include @@ -19,38 +17,40 @@ #include #include // for std::ptrdiff_t #include // for std::memmove + +#include "format.h" #if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) -# include +#include #endif #if FMT_USE_WINDOWS_H -# if !defined(FMT_HEADER_ONLY) && !defined(WIN32_LEAN_AND_MEAN) -# define WIN32_LEAN_AND_MEAN -# endif -# if defined(NOMINMAX) || defined(FMT_WIN_MINMAX) -# include -# else -# define NOMINMAX -# include -# undef NOMINMAX -# endif +#if !defined(FMT_HEADER_ONLY) && !defined(WIN32_LEAN_AND_MEAN) +#define WIN32_LEAN_AND_MEAN +#endif +#if defined(NOMINMAX) || defined(FMT_WIN_MINMAX) +#include +#else +#define NOMINMAX +#include +#undef NOMINMAX +#endif #endif #if FMT_EXCEPTIONS -# define FMT_TRY try -# define FMT_CATCH(x) catch (x) +#define FMT_TRY try +#define FMT_CATCH(x) catch (x) #else -# define FMT_TRY if (true) -# define FMT_CATCH(x) if (false) +#define FMT_TRY if (true) +#define FMT_CATCH(x) if (false) #endif #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -# pragma warning(disable: 4702) // unreachable code +#pragma warning(push) +#pragma warning(disable : 4127) // conditional expression is constant +#pragma warning(disable : 4702) // unreachable code // Disable deprecation warning for strerror. The latter is not called but // MSVC fails to detect it. -# pragma warning(disable: 4996) +#pragma warning(disable : 4996) #endif // Dummy implementations of strerror_r and strerror_s called if corresponding @@ -67,7 +67,7 @@ FMT_BEGIN_NAMESPACE namespace { #ifndef _MSC_VER -# define FMT_SNPRINTF snprintf +#define FMT_SNPRINTF snprintf #else // _MSC_VER inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) { va_list args; @@ -76,14 +76,14 @@ inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) { va_end(args); return result; } -# define FMT_SNPRINTF fmt_snprintf +#define FMT_SNPRINTF fmt_snprintf #endif // _MSC_VER #if defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT) -# define FMT_SWPRINTF snwprintf +#define FMT_SWPRINTF snwprintf #else -# define FMT_SWPRINTF swprintf -#endif // defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT) +#define FMT_SWPRINTF swprintf +#endif // defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT) typedef void (*FormatFunc)(internal::buffer &, int, string_view); @@ -96,8 +96,8 @@ typedef void (*FormatFunc)(internal::buffer &, int, string_view); // ERANGE - buffer is not large enough to store the error message // other - failure // Buffer should be at least of size 1. -int safe_strerror( - int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT { +int safe_strerror(int error_code, char *&buffer, + std::size_t buffer_size) FMT_NOEXCEPT { FMT_ASSERT(buffer != FMT_NULL && buffer_size != 0, "invalid buffer"); class dispatcher { @@ -132,8 +132,8 @@ int safe_strerror( // Fallback to strerror_s when strerror_r is not available. int fallback(int result) { // If the buffer is full then the message is probably truncated. - return result == 0 && strlen(buffer_) == buffer_size_ - 1 ? - ERANGE : result; + return result == 0 && strlen(buffer_) == buffer_size_ - 1 ? ERANGE + : result; } #if !FMT_MSC_VER @@ -147,11 +147,9 @@ int safe_strerror( public: dispatcher(int err_code, char *&buf, std::size_t buf_size) - : error_code_(err_code), buffer_(buf), buffer_size_(buf_size) {} + : error_code_(err_code), buffer_(buf), buffer_size_(buf_size) {} - int run() { - return handle(strerror_r(error_code_, buffer_, buffer_size_)); - } + int run() { return handle(strerror_r(error_code_, buffer_, buffer_size_)); } }; return dispatcher(error_code, buffer, buffer_size).run(); } @@ -198,8 +196,7 @@ FMT_FUNC size_t internal::count_code_points(basic_string_view s) { const char8_t *data = s.data(); size_t num_code_points = 0; for (size_t i = 0, size = s.size(); i != size; ++i) { - if ((data[i] & 0xc0) != 0x80) - ++num_code_points; + if ((data[i] & 0xc0) != 0x80) ++num_code_points; } return num_code_points; } @@ -215,15 +212,15 @@ locale_ref::locale_ref(const Locale &loc) : locale_(&loc) { template Locale locale_ref::get() const { static_assert(std::is_same::value, ""); - return locale_ ? *static_cast(locale_) : std::locale(); + return locale_ ? *static_cast(locale_) : std::locale(); } template FMT_FUNC Char thousands_sep_impl(locale_ref loc) { - return std::use_facet >( - loc.get()).thousands_sep(); -} + return std::use_facet >(loc.get()) + .thousands_sep(); } +} // namespace internal #else template FMT_FUNC Char internal::thousands_sep_impl(locale_ref) { @@ -231,8 +228,8 @@ FMT_FUNC Char internal::thousands_sep_impl(locale_ref) { } #endif -FMT_FUNC void system_error::init( - int err_code, string_view format_str, format_args args) { +FMT_FUNC void system_error::init(int err_code, string_view format_str, + format_args args) { error_code_ = err_code; memory_buffer buffer; format_system_error(buffer, err_code, vformat(format_str, args)); @@ -242,20 +239,19 @@ FMT_FUNC void system_error::init( namespace internal { template -int char_traits::format_float( - char *buf, std::size_t size, const char *format, int precision, T value) { - return precision < 0 ? - FMT_SNPRINTF(buf, size, format, value) : - FMT_SNPRINTF(buf, size, format, precision, value); +int char_traits::format_float(char *buf, std::size_t size, + const char *format, int precision, + T value) { + return precision < 0 ? FMT_SNPRINTF(buf, size, format, value) + : FMT_SNPRINTF(buf, size, format, precision, value); } template -int char_traits::format_float( - wchar_t *buf, std::size_t size, const wchar_t *format, int precision, - T value) { - return precision < 0 ? - FMT_SWPRINTF(buf, size, format, value) : - FMT_SWPRINTF(buf, size, format, precision, value); +int char_traits::format_float(wchar_t *buf, std::size_t size, + const wchar_t *format, int precision, + T value) { + return precision < 0 ? FMT_SWPRINTF(buf, size, format, value) + : FMT_SWPRINTF(buf, size, format, precision, value); } template @@ -266,88 +262,79 @@ const char basic_data::DIGITS[] = "6061626364656667686970717273747576777879" "8081828384858687888990919293949596979899"; -#define FMT_POWERS_OF_10(factor) \ - factor * 10, \ - factor * 100, \ - factor * 1000, \ - factor * 10000, \ - factor * 100000, \ - factor * 1000000, \ - factor * 10000000, \ - factor * 100000000, \ - factor * 1000000000 +#define FMT_POWERS_OF_10(factor) \ + factor * 10, factor * 100, factor * 1000, factor * 10000, factor * 100000, \ + factor * 1000000, factor * 10000000, factor * 100000000, \ + factor * 1000000000 template -const uint32_t basic_data::POWERS_OF_10_32[] = { - 1, FMT_POWERS_OF_10(1) -}; +const uint32_t basic_data::POWERS_OF_10_32[] = {1, FMT_POWERS_OF_10(1)}; template -const uint32_t basic_data::ZERO_OR_POWERS_OF_10_32[] = { - 0, FMT_POWERS_OF_10(1) -}; +const uint32_t basic_data::ZERO_OR_POWERS_OF_10_32[] = {0, + FMT_POWERS_OF_10(1)}; template const uint64_t basic_data::ZERO_OR_POWERS_OF_10_64[] = { - 0, - FMT_POWERS_OF_10(1), - FMT_POWERS_OF_10(1000000000ull), - 10000000000000000000ull -}; + 0, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ull), + 10000000000000000000ull}; // Normalized 64-bit significands of pow(10, k), for k = -348, -340, ..., 340. // These are generated by support/compute-powers.py. template const uint64_t basic_data::POW10_SIGNIFICANDS[] = { - 0xfa8fd5a0081c0288, 0xbaaee17fa23ebf76, 0x8b16fb203055ac76, - 0xcf42894a5dce35ea, 0x9a6bb0aa55653b2d, 0xe61acf033d1a45df, - 0xab70fe17c79ac6ca, 0xff77b1fcbebcdc4f, 0xbe5691ef416bd60c, - 0x8dd01fad907ffc3c, 0xd3515c2831559a83, 0x9d71ac8fada6c9b5, - 0xea9c227723ee8bcb, 0xaecc49914078536d, 0x823c12795db6ce57, - 0xc21094364dfb5637, 0x9096ea6f3848984f, 0xd77485cb25823ac7, - 0xa086cfcd97bf97f4, 0xef340a98172aace5, 0xb23867fb2a35b28e, - 0x84c8d4dfd2c63f3b, 0xc5dd44271ad3cdba, 0x936b9fcebb25c996, - 0xdbac6c247d62a584, 0xa3ab66580d5fdaf6, 0xf3e2f893dec3f126, - 0xb5b5ada8aaff80b8, 0x87625f056c7c4a8b, 0xc9bcff6034c13053, - 0x964e858c91ba2655, 0xdff9772470297ebd, 0xa6dfbd9fb8e5b88f, - 0xf8a95fcf88747d94, 0xb94470938fa89bcf, 0x8a08f0f8bf0f156b, - 0xcdb02555653131b6, 0x993fe2c6d07b7fac, 0xe45c10c42a2b3b06, - 0xaa242499697392d3, 0xfd87b5f28300ca0e, 0xbce5086492111aeb, - 0x8cbccc096f5088cc, 0xd1b71758e219652c, 0x9c40000000000000, - 0xe8d4a51000000000, 0xad78ebc5ac620000, 0x813f3978f8940984, - 0xc097ce7bc90715b3, 0x8f7e32ce7bea5c70, 0xd5d238a4abe98068, - 0x9f4f2726179a2245, 0xed63a231d4c4fb27, 0xb0de65388cc8ada8, - 0x83c7088e1aab65db, 0xc45d1df942711d9a, 0x924d692ca61be758, - 0xda01ee641a708dea, 0xa26da3999aef774a, 0xf209787bb47d6b85, - 0xb454e4a179dd1877, 0x865b86925b9bc5c2, 0xc83553c5c8965d3d, - 0x952ab45cfa97a0b3, 0xde469fbd99a05fe3, 0xa59bc234db398c25, - 0xf6c69a72a3989f5c, 0xb7dcbf5354e9bece, 0x88fcf317f22241e2, - 0xcc20ce9bd35c78a5, 0x98165af37b2153df, 0xe2a0b5dc971f303a, - 0xa8d9d1535ce3b396, 0xfb9b7cd9a4a7443c, 0xbb764c4ca7a44410, - 0x8bab8eefb6409c1a, 0xd01fef10a657842c, 0x9b10a4e5e9913129, - 0xe7109bfba19c0c9d, 0xac2820d9623bf429, 0x80444b5e7aa7cf85, - 0xbf21e44003acdd2d, 0x8e679c2f5e44ff8f, 0xd433179d9c8cb841, - 0x9e19db92b4e31ba9, 0xeb96bf6ebadf77d9, 0xaf87023b9bf0ee6b, + 0xfa8fd5a0081c0288, 0xbaaee17fa23ebf76, 0x8b16fb203055ac76, + 0xcf42894a5dce35ea, 0x9a6bb0aa55653b2d, 0xe61acf033d1a45df, + 0xab70fe17c79ac6ca, 0xff77b1fcbebcdc4f, 0xbe5691ef416bd60c, + 0x8dd01fad907ffc3c, 0xd3515c2831559a83, 0x9d71ac8fada6c9b5, + 0xea9c227723ee8bcb, 0xaecc49914078536d, 0x823c12795db6ce57, + 0xc21094364dfb5637, 0x9096ea6f3848984f, 0xd77485cb25823ac7, + 0xa086cfcd97bf97f4, 0xef340a98172aace5, 0xb23867fb2a35b28e, + 0x84c8d4dfd2c63f3b, 0xc5dd44271ad3cdba, 0x936b9fcebb25c996, + 0xdbac6c247d62a584, 0xa3ab66580d5fdaf6, 0xf3e2f893dec3f126, + 0xb5b5ada8aaff80b8, 0x87625f056c7c4a8b, 0xc9bcff6034c13053, + 0x964e858c91ba2655, 0xdff9772470297ebd, 0xa6dfbd9fb8e5b88f, + 0xf8a95fcf88747d94, 0xb94470938fa89bcf, 0x8a08f0f8bf0f156b, + 0xcdb02555653131b6, 0x993fe2c6d07b7fac, 0xe45c10c42a2b3b06, + 0xaa242499697392d3, 0xfd87b5f28300ca0e, 0xbce5086492111aeb, + 0x8cbccc096f5088cc, 0xd1b71758e219652c, 0x9c40000000000000, + 0xe8d4a51000000000, 0xad78ebc5ac620000, 0x813f3978f8940984, + 0xc097ce7bc90715b3, 0x8f7e32ce7bea5c70, 0xd5d238a4abe98068, + 0x9f4f2726179a2245, 0xed63a231d4c4fb27, 0xb0de65388cc8ada8, + 0x83c7088e1aab65db, 0xc45d1df942711d9a, 0x924d692ca61be758, + 0xda01ee641a708dea, 0xa26da3999aef774a, 0xf209787bb47d6b85, + 0xb454e4a179dd1877, 0x865b86925b9bc5c2, 0xc83553c5c8965d3d, + 0x952ab45cfa97a0b3, 0xde469fbd99a05fe3, 0xa59bc234db398c25, + 0xf6c69a72a3989f5c, 0xb7dcbf5354e9bece, 0x88fcf317f22241e2, + 0xcc20ce9bd35c78a5, 0x98165af37b2153df, 0xe2a0b5dc971f303a, + 0xa8d9d1535ce3b396, 0xfb9b7cd9a4a7443c, 0xbb764c4ca7a44410, + 0x8bab8eefb6409c1a, 0xd01fef10a657842c, 0x9b10a4e5e9913129, + 0xe7109bfba19c0c9d, 0xac2820d9623bf429, 0x80444b5e7aa7cf85, + 0xbf21e44003acdd2d, 0x8e679c2f5e44ff8f, 0xd433179d9c8cb841, + 0x9e19db92b4e31ba9, 0xeb96bf6ebadf77d9, 0xaf87023b9bf0ee6b, }; // Binary exponents of pow(10, k), for k = -348, -340, ..., 340, corresponding // to significands above. template const int16_t basic_data::POW10_EXPONENTS[] = { - -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980, -954, - -927, -901, -874, -847, -821, -794, -768, -741, -715, -688, -661, - -635, -608, -582, -555, -529, -502, -475, -449, -422, -396, -369, - -343, -316, -289, -263, -236, -210, -183, -157, -130, -103, -77, - -50, -24, 3, 30, 56, 83, 109, 136, 162, 189, 216, - 242, 269, 295, 322, 348, 375, 402, 428, 455, 481, 508, - 534, 561, 588, 614, 641, 667, 694, 720, 747, 774, 800, - 827, 853, 880, 907, 933, 960, 986, 1013, 1039, 1066 -}; + -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980, -954, + -927, -901, -874, -847, -821, -794, -768, -741, -715, -688, -661, + -635, -608, -582, -555, -529, -502, -475, -449, -422, -396, -369, + -343, -316, -289, -263, -236, -210, -183, -157, -130, -103, -77, + -50, -24, 3, 30, 56, 83, 109, 136, 162, 189, 216, + 242, 269, 295, 322, 348, 375, 402, 428, 455, 481, 508, + 534, 561, 588, 614, 641, 667, 694, 720, 747, 774, 800, + 827, 853, 880, 907, 933, 960, 986, 1013, 1039, 1066}; -template const char basic_data::FOREGROUND_COLOR[] = "\x1b[38;2;"; -template const char basic_data::BACKGROUND_COLOR[] = "\x1b[48;2;"; -template const char basic_data::RESET_COLOR[] = "\x1b[0m"; -template const wchar_t basic_data::WRESET_COLOR[] = L"\x1b[0m"; +template +const char basic_data::FOREGROUND_COLOR[] = "\x1b[38;2;"; +template +const char basic_data::BACKGROUND_COLOR[] = "\x1b[48;2;"; +template +const char basic_data::RESET_COLOR[] = "\x1b[0m"; +template +const wchar_t basic_data::WRESET_COLOR[] = L"\x1b[0m"; // A handmade floating-point number f * pow(2, e). class fp { @@ -356,23 +343,23 @@ class fp { // All sizes are in bits. static FMT_CONSTEXPR_DECL const int char_size = - std::numeric_limits::digits; + std::numeric_limits::digits; // Subtract 1 to account for an implicit most significant bit in the // normalized form. static FMT_CONSTEXPR_DECL const int double_significand_size = - std::numeric_limits::digits - 1; + std::numeric_limits::digits - 1; static FMT_CONSTEXPR_DECL const uint64_t implicit_bit = - 1ull << double_significand_size; + 1ull << double_significand_size; public: significand_type f; int e; static FMT_CONSTEXPR_DECL const int significand_size = - sizeof(significand_type) * char_size; + sizeof(significand_type) * char_size; - fp(): f(0), e(0) {} - fp(uint64_t f_val, int e_val): f(f_val), e(e_val) {} + fp() : f(0), e(0) {} + fp(uint64_t f_val, int e_val) : f(f_val), e(e_val) {} // Constructs fp from an IEEE754 double. It is a template to prevent compile // errors on platforms where double is not IEEE754. @@ -382,7 +369,7 @@ class fp { typedef std::numeric_limits limits; const int double_size = static_cast(sizeof(Double) * char_size); const int exponent_size = - double_size - double_significand_size - 1; // -1 for sign + double_size - double_significand_size - 1; // -1 for sign const uint64_t significand_mask = implicit_bit - 1; const uint64_t exponent_mask = (~0ull >> 1) & ~significand_mask; const int exponent_bias = (1 << exponent_size) - limits::max_exponent - 1; @@ -416,8 +403,8 @@ class fp { // (lower) or successor (upper). The upper boundary is normalized and lower // has the same exponent but may be not normalized. void compute_boundaries(fp &lower, fp &upper) const { - lower = f == implicit_bit ? - fp((f << 2) - 1, e - 2) : fp((f << 1) - 1, e - 1); + lower = + f == implicit_bit ? fp((f << 2) - 1, e - 2) : fp((f << 1) - 1, e - 1); upper = fp((f << 1) + 1, e - 1); upper.normalize<1>(); // 1 is to account for the exponent shift above. lower.f <<= lower.e - upper.e; @@ -432,7 +419,8 @@ inline fp operator-(fp x, fp y) { } // Computes an fp number r with r.f = x.f * y.f / pow(2, 64) rounded to nearest -// with half-up tie breaking, r.e = x.e + y.e + 64. Result may not be normalized. +// with half-up tie breaking, r.e = x.e + y.e + 64. Result may not be +// normalized. FMT_API fp operator*(fp x, fp y); // Returns cached power (of 10) c_k = c_k.f * pow(2, c_k.e) such that its @@ -452,8 +440,8 @@ FMT_FUNC fp operator*(fp x, fp y) { FMT_FUNC fp get_cached_power(int min_exponent, int &pow10_exponent) { const double one_over_log2_10 = 0.30102999566398114; // 1 / log2(10) - int index = static_cast(std::ceil( - (min_exponent + fp::significand_size - 1) * one_over_log2_10)); + int index = static_cast( + std::ceil((min_exponent + fp::significand_size - 1) * one_over_log2_10)); // Decimal exponent of the first (smallest) cached power of 10. const int first_dec_exp = -348; // Difference between 2 consecutive decimal exponents in cached powers of 10. @@ -463,55 +451,84 @@ FMT_FUNC fp get_cached_power(int min_exponent, int &pow10_exponent) { return fp(data::POW10_SIGNIFICANDS[index], data::POW10_EXPONENTS[index]); } -FMT_FUNC bool grisu2_round( - char *buf, int &size, int max_digits, uint64_t delta, - uint64_t remainder, uint64_t exp, uint64_t diff, int &exp10) { - while (remainder < diff && delta - remainder >= exp && - (remainder + exp < diff || diff - remainder > remainder + exp - diff)) { +FMT_FUNC bool grisu2_round(char *buf, int &size, int max_digits, uint64_t delta, + uint64_t remainder, uint64_t exp, uint64_t diff, + int &exp10) { + while ( + remainder < diff && delta - remainder >= exp && + (remainder + exp < diff || diff - remainder > remainder + exp - diff)) { --buf[size - 1]; remainder += exp; } if (size > max_digits) { --size; ++exp10; - if (buf[size] >= '5') - return false; + if (buf[size] >= '5') return false; } return true; } // Generates output using Grisu2 digit-gen algorithm. -FMT_FUNC bool grisu2_gen_digits( - char *buf, int &size, uint32_t hi, uint64_t lo, int &exp, - uint64_t delta, const fp &one, const fp &diff, int max_digits) { +FMT_FUNC bool grisu2_gen_digits(char *buf, int &size, uint32_t hi, uint64_t lo, + int &exp, uint64_t delta, const fp &one, + const fp &diff, int max_digits) { // Generate digits for the most significant part (hi). while (exp > 0) { uint32_t digit = 0; // This optimization by miloyip reduces the number of integer divisions by // one per iteration. switch (exp) { - case 10: digit = hi / 1000000000; hi %= 1000000000; break; - case 9: digit = hi / 100000000; hi %= 100000000; break; - case 8: digit = hi / 10000000; hi %= 10000000; break; - case 7: digit = hi / 1000000; hi %= 1000000; break; - case 6: digit = hi / 100000; hi %= 100000; break; - case 5: digit = hi / 10000; hi %= 10000; break; - case 4: digit = hi / 1000; hi %= 1000; break; - case 3: digit = hi / 100; hi %= 100; break; - case 2: digit = hi / 10; hi %= 10; break; - case 1: digit = hi; hi = 0; break; - default: - FMT_ASSERT(false, "invalid number of digits"); + case 10: + digit = hi / 1000000000; + hi %= 1000000000; + break; + case 9: + digit = hi / 100000000; + hi %= 100000000; + break; + case 8: + digit = hi / 10000000; + hi %= 10000000; + break; + case 7: + digit = hi / 1000000; + hi %= 1000000; + break; + case 6: + digit = hi / 100000; + hi %= 100000; + break; + case 5: + digit = hi / 10000; + hi %= 10000; + break; + case 4: + digit = hi / 1000; + hi %= 1000; + break; + case 3: + digit = hi / 100; + hi %= 100; + break; + case 2: + digit = hi / 10; + hi %= 10; + break; + case 1: + digit = hi; + hi = 0; + break; + default: + FMT_ASSERT(false, "invalid number of digits"); } - if (digit != 0 || size != 0) - buf[size++] = static_cast('0' + digit); + if (digit != 0 || size != 0) buf[size++] = static_cast('0' + digit); --exp; uint64_t remainder = (static_cast(hi) << -one.e) + lo; if (remainder <= delta || size > max_digits) { return grisu2_round( - buf, size, max_digits, delta, remainder, - static_cast(data::POWERS_OF_10_32[exp]) << -one.e, - diff.f, exp); + buf, size, max_digits, delta, remainder, + static_cast(data::POWERS_OF_10_32[exp]) << -one.e, diff.f, + exp); } } // Generate digits for the least significant part (lo). @@ -519,8 +536,7 @@ FMT_FUNC bool grisu2_gen_digits( lo *= 10; delta *= 10; char digit = static_cast(lo >> -one.e); - if (digit != 0 || size != 0) - buf[size++] = static_cast('0' + digit); + if (digit != 0 || size != 0) buf[size++] = static_cast('0' + digit); lo &= one.f - 1; --exp; if (lo < delta || size > max_digits) { @@ -531,11 +547,11 @@ FMT_FUNC bool grisu2_gen_digits( } #if FMT_CLANG_VERSION -# define FMT_FALLTHROUGH [[clang::fallthrough]]; +#define FMT_FALLTHROUGH [[clang::fallthrough]]; #elif FMT_GCC_VERSION >= 700 -# define FMT_FALLTHROUGH [[gnu::fallthrough]]; +#define FMT_FALLTHROUGH [[gnu::fallthrough]]; #else -# define FMT_FALLTHROUGH +#define FMT_FALLTHROUGH #endif struct gen_digits_params { @@ -551,7 +567,7 @@ struct prettify_handler { buffer &buf; explicit prettify_handler(buffer &b, ptrdiff_t n) - : data(b.data()), size(n), buf(b) {} + : data(b.data()), size(n), buf(b) {} ~prettify_handler() { assert(buf.size() >= to_unsigned(size)); buf.resize(to_unsigned(size)); @@ -616,14 +632,13 @@ struct fill { // The number is given as v = f * pow(10, exp), where f has size digits. template -FMT_FUNC void grisu2_prettify(const gen_digits_params ¶ms, - int size, int exp, Handler &&handler) { +FMT_FUNC void grisu2_prettify(const gen_digits_params ¶ms, int size, + int exp, Handler &&handler) { if (!params.fixed) { // Insert a decimal point after the first digit and add an exponent. handler.insert(1, '.'); exp += size - 1; - if (size < params.num_digits) - handler.append(params.num_digits - size, '0'); + if (size < params.num_digits) handler.append(params.num_digits - size, '0'); handler.append(params.upper ? 'E' : 'e'); write_exponent(exp, handler); return; @@ -660,7 +675,9 @@ struct char_counter { ptrdiff_t size; template - void insert(ptrdiff_t, ptrdiff_t n, F) { size += n; } + void insert(ptrdiff_t, ptrdiff_t n, F) { + size += n; + } void insert(ptrdiff_t, char) { ++size; } void append(ptrdiff_t n, char) { size += n; } void append(char) { ++size; } @@ -675,34 +692,34 @@ FMT_FUNC gen_digits_params process_specs(const core_format_specs &specs, auto params = gen_digits_params(); int num_digits = specs.precision >= 0 ? specs.precision : 6; switch (specs.type) { - case 'G': - params.upper = true; - FMT_FALLTHROUGH - case '\0': case 'g': - params.trailing_zeros = (specs.flags & HASH_FLAG) != 0; - if (-4 <= exp && exp < num_digits + 1) { + case 'G': + params.upper = true; + FMT_FALLTHROUGH + case '\0': + case 'g': + params.trailing_zeros = (specs.flags & HASH_FLAG) != 0; + if (-4 <= exp && exp < num_digits + 1) { + params.fixed = true; + if (!specs.type && params.trailing_zeros && exp >= 0) + num_digits = exp + 1; + } + break; + case 'F': + params.upper = true; + FMT_FALLTHROUGH + case 'f': { params.fixed = true; - if (!specs.type && params.trailing_zeros && exp >= 0) - num_digits = exp + 1; + params.trailing_zeros = true; + int adjusted_min_digits = num_digits + exp; + if (adjusted_min_digits > 0) num_digits = adjusted_min_digits; + break; } - break; - case 'F': - params.upper = true; - FMT_FALLTHROUGH - case 'f': { - params.fixed = true; - params.trailing_zeros = true; - int adjusted_min_digits = num_digits + exp; - if (adjusted_min_digits > 0) - num_digits = adjusted_min_digits; - break; - } - case 'E': - params.upper = true; - FMT_FALLTHROUGH - case 'e': - ++num_digits; - break; + case 'E': + params.upper = true; + FMT_FALLTHROUGH + case 'e': + ++num_digits; + break; } params.num_digits = num_digits; char_counter counter{num_digits}; @@ -713,7 +730,7 @@ FMT_FUNC gen_digits_params process_specs(const core_format_specs &specs, template FMT_FUNC typename std::enable_if::type - grisu2_format(Double value, buffer &buf, core_format_specs specs) { +grisu2_format(Double value, buffer &buf, core_format_specs specs) { FMT_ASSERT(value >= 0, "value is negative"); if (value == 0) { gen_digits_params params = process_specs(specs, 1, buf); @@ -728,13 +745,13 @@ FMT_FUNC typename std::enable_if::type fp_value.compute_boundaries(lower, upper); // Find a cached power of 10 close to 1 / upper and use it to scale upper. - const int min_exp = -60; // alpha in Grisu. - int cached_exp = 0; // K in Grisu. + const int min_exp = -60; // alpha in Grisu. + int cached_exp = 0; // K in Grisu. auto cached_pow = get_cached_power( // \tilde{c}_{-k} in Grisu. min_exp - (upper.e + fp::significand_size), cached_exp); cached_exp = -cached_exp; upper = upper * cached_pow; // \tilde{M}^+ in Grisu. - --upper.f; // \tilde{M}^+ - 1 ulp -> M^+_{\downarrow}. + --upper.f; // \tilde{M}^+ - 1 ulp -> M^+_{\downarrow}. fp one(1ull << -upper.e, upper.e); // hi (p1 in Grisu) contains the most significant digits of scaled_upper. // hi = floor(upper / one). @@ -744,9 +761,9 @@ FMT_FUNC typename std::enable_if::type fp_value.normalize(); fp scaled_value = fp_value * cached_pow; lower = lower * cached_pow; // \tilde{M}^- in Grisu. - ++lower.f; // \tilde{M}^- + 1 ulp -> M^-_{\uparrow}. + ++lower.f; // \tilde{M}^- + 1 ulp -> M^-_{\uparrow}. uint64_t delta = upper.f - lower.f; - fp diff = upper - scaled_value; // wp_w in Grisu. + fp diff = upper - scaled_value; // wp_w in Grisu. // lo (p2 in Grisu) contains the least significants digits of scaled_upper. // lo = supper % one. uint64_t lo = upper.f & (one.f - 1); @@ -767,18 +784,16 @@ void sprintf_format(Double value, internal::buffer &buf, FMT_ASSERT(buf.capacity() != 0, "empty buffer"); // Build format string. - enum { MAX_FORMAT_SIZE = 10}; // longest format: %#-*.*Lg + enum { MAX_FORMAT_SIZE = 10 }; // longest format: %#-*.*Lg char format[MAX_FORMAT_SIZE]; char *format_ptr = format; *format_ptr++ = '%'; - if (spec.has(HASH_FLAG)) - *format_ptr++ = '#'; + if (spec.has(HASH_FLAG)) *format_ptr++ = '#'; if (spec.precision >= 0) { *format_ptr++ = '.'; *format_ptr++ = '*'; } - if (std::is_same::value) - *format_ptr++ = 'L'; + if (std::is_same::value) *format_ptr++ = 'L'; *format_ptr++ = spec.type; *format_ptr = '\0'; @@ -819,28 +834,25 @@ FMT_FUNC internal::utf8_to_utf16::utf8_to_utf16(string_view s) { return; } - int length = MultiByteToWideChar( - CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, FMT_NULL, 0); - if (length == 0) - FMT_THROW(windows_error(GetLastError(), ERROR_MSG)); + int length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), + s_size, FMT_NULL, 0); + if (length == 0) FMT_THROW(windows_error(GetLastError(), ERROR_MSG)); buffer_.resize(length + 1); - length = MultiByteToWideChar( - CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, &buffer_[0], length); - if (length == 0) - FMT_THROW(windows_error(GetLastError(), ERROR_MSG)); + length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, + &buffer_[0], length); + if (length == 0) FMT_THROW(windows_error(GetLastError(), ERROR_MSG)); buffer_[length] = 0; } FMT_FUNC internal::utf16_to_utf8::utf16_to_utf8(wstring_view s) { if (int error_code = convert(s)) { FMT_THROW(windows_error(error_code, - "cannot convert string from UTF-16 to UTF-8")); + "cannot convert string from UTF-16 to UTF-8")); } } FMT_FUNC int internal::utf16_to_utf8::convert(wstring_view s) { - if (s.size() > INT_MAX) - return ERROR_INVALID_PARAMETER; + if (s.size() > INT_MAX) return ERROR_INVALID_PARAMETER; int s_size = static_cast(s.size()); if (s_size == 0) { // WideCharToMultiByte does not support zero length, handle separately. @@ -849,21 +861,19 @@ FMT_FUNC int internal::utf16_to_utf8::convert(wstring_view s) { return 0; } - int length = WideCharToMultiByte( - CP_UTF8, 0, s.data(), s_size, FMT_NULL, 0, FMT_NULL, FMT_NULL); - if (length == 0) - return GetLastError(); + int length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, FMT_NULL, 0, + FMT_NULL, FMT_NULL); + if (length == 0) return GetLastError(); buffer_.resize(length + 1); - length = WideCharToMultiByte( - CP_UTF8, 0, s.data(), s_size, &buffer_[0], length, FMT_NULL, FMT_NULL); - if (length == 0) - return GetLastError(); + length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, &buffer_[0], + length, FMT_NULL, FMT_NULL); + if (length == 0) return GetLastError(); buffer_[length] = 0; return 0; } -FMT_FUNC void windows_error::init( - int err_code, string_view format_str, format_args args) { +FMT_FUNC void windows_error::init(int err_code, string_view format_str, + format_args args) { error_code_ = err_code; memory_buffer buffer; internal::format_windows_error(buffer, err_code, vformat(format_str, args)); @@ -871,17 +881,18 @@ FMT_FUNC void windows_error::init( base = std::runtime_error(to_string(buffer)); } -FMT_FUNC void internal::format_windows_error( - internal::buffer &out, int error_code, string_view message) FMT_NOEXCEPT { +FMT_FUNC void internal::format_windows_error(internal::buffer &out, + int error_code, + string_view message) FMT_NOEXCEPT { FMT_TRY { wmemory_buffer buf; buf.resize(inline_buffer_size); for (;;) { wchar_t *system_message = &buf[0]; int result = FormatMessageW( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - FMT_NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - system_message, static_cast(buf.size()), FMT_NULL); + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, FMT_NULL, + error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), system_message, + static_cast(buf.size()), FMT_NULL); if (result != 0) { utf16_to_utf8 utf8_message; if (utf8_message.convert(system_message) == ERROR_SUCCESS) { @@ -897,14 +908,15 @@ FMT_FUNC void internal::format_windows_error( break; // Can't get error message, report error code instead. buf.resize(buf.size() * 2); } - } FMT_CATCH(...) {} + } + FMT_CATCH(...) {} format_error_code(out, error_code, message); } #endif // FMT_USE_WINDOWS_H -FMT_FUNC void format_system_error( - internal::buffer &out, int error_code, string_view message) FMT_NOEXCEPT { +FMT_FUNC void format_system_error(internal::buffer &out, int error_code, + string_view message) FMT_NOEXCEPT { FMT_TRY { memory_buffer buf; buf.resize(inline_buffer_size); @@ -922,7 +934,8 @@ FMT_FUNC void format_system_error( break; // Can't get error message, report error code instead. buf.resize(buf.size() * 2); } - } FMT_CATCH(...) {} + } + FMT_CATCH(...) {} format_error_code(out, error_code, message); } @@ -930,14 +943,14 @@ FMT_FUNC void internal::error_handler::on_error(const char *message) { FMT_THROW(format_error(message)); } -FMT_FUNC void report_system_error( - int error_code, fmt::string_view message) FMT_NOEXCEPT { +FMT_FUNC void report_system_error(int error_code, + fmt::string_view message) FMT_NOEXCEPT { report_error(format_system_error, error_code, message); } #if FMT_USE_WINDOWS_H -FMT_FUNC void report_windows_error( - int error_code, fmt::string_view message) FMT_NOEXCEPT { +FMT_FUNC void report_windows_error(int error_code, + fmt::string_view message) FMT_NOEXCEPT { report_error(internal::format_windows_error, error_code, message); } #endif @@ -966,7 +979,7 @@ FMT_FUNC void vprint(wstring_view format_str, wformat_args args) { FMT_END_NAMESPACE #ifdef _MSC_VER -# pragma warning(pop) +#pragma warning(pop) #endif #endif // FMT_FORMAT_INL_H_ diff --git a/src/cpp/include/deps/spdlog/fmt/bundled/format.h b/src/cpp/include/deps/spdlog/fmt/bundled/format.h old mode 100755 new mode 100644 index 1bb24a529..0e39ddcdd --- a/src/cpp/include/deps/spdlog/fmt/bundled/format.h +++ b/src/cpp/include/deps/spdlog/fmt/bundled/format.h @@ -28,6 +28,8 @@ #ifndef FMT_FORMAT_H_ #define FMT_FORMAT_H_ +#include + #include #include #include @@ -35,69 +37,68 @@ #include #include #include -#include #ifdef __clang__ -# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) +#define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) #else -# define FMT_CLANG_VERSION 0 +#define FMT_CLANG_VERSION 0 #endif #ifdef __INTEL_COMPILER -# define FMT_ICC_VERSION __INTEL_COMPILER +#define FMT_ICC_VERSION __INTEL_COMPILER #elif defined(__ICL) -# define FMT_ICC_VERSION __ICL +#define FMT_ICC_VERSION __ICL #else -# define FMT_ICC_VERSION 0 +#define FMT_ICC_VERSION 0 #endif #ifdef __NVCC__ -# define FMT_CUDA_VERSION (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__) +#define FMT_CUDA_VERSION (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__) #else -# define FMT_CUDA_VERSION 0 +#define FMT_CUDA_VERSION 0 #endif #include "core.h" #if FMT_GCC_VERSION >= 406 || FMT_CLANG_VERSION -# pragma GCC diagnostic push +#pragma GCC diagnostic push // Disable the warning about declaration shadowing because it affects too // many valid cases. -# pragma GCC diagnostic ignored "-Wshadow" +#pragma GCC diagnostic ignored "-Wshadow" // Disable the warning about nonliteral format strings because we construct // them dynamically when falling back to snprintf for FP formatting. -# pragma GCC diagnostic ignored "-Wformat-nonliteral" +#pragma GCC diagnostic ignored "-Wformat-nonliteral" #endif -# if FMT_CLANG_VERSION -# pragma GCC diagnostic ignored "-Wgnu-string-literal-operator-template" -# endif +#if FMT_CLANG_VERSION +#pragma GCC diagnostic ignored "-Wgnu-string-literal-operator-template" +#endif #ifdef _SECURE_SCL -# define FMT_SECURE_SCL _SECURE_SCL +#define FMT_SECURE_SCL _SECURE_SCL #else -# define FMT_SECURE_SCL 0 +#define FMT_SECURE_SCL 0 #endif #if FMT_SECURE_SCL -# include +#include #endif #ifdef __has_builtin -# define FMT_HAS_BUILTIN(x) __has_builtin(x) +#define FMT_HAS_BUILTIN(x) __has_builtin(x) #else -# define FMT_HAS_BUILTIN(x) 0 +#define FMT_HAS_BUILTIN(x) 0 #endif #ifdef __GNUC_LIBSTD__ -# define FMT_GNUC_LIBSTD_VERSION (__GNUC_LIBSTD__ * 100 + __GNUC_LIBSTD_MINOR__) +#define FMT_GNUC_LIBSTD_VERSION (__GNUC_LIBSTD__ * 100 + __GNUC_LIBSTD_MINOR__) #endif #ifndef FMT_THROW -# if FMT_EXCEPTIONS -# if FMT_MSC_VER +#if FMT_EXCEPTIONS +#if FMT_MSC_VER FMT_BEGIN_NAMESPACE namespace internal { template @@ -105,91 +106,93 @@ inline void do_throw(const Exception &x) { // Silence unreachable code warnings in MSVC because these are nearly // impossible to fix in a generic code. volatile bool b = true; - if (b) - throw x; -} + if (b) throw x; } +} // namespace internal FMT_END_NAMESPACE -# define FMT_THROW(x) fmt::internal::do_throw(x) -# else -# define FMT_THROW(x) throw x -# endif -# else -# define FMT_THROW(x) do { static_cast(sizeof(x)); assert(false); } while(false); -# endif +#define FMT_THROW(x) fmt::internal::do_throw(x) +#else +#define FMT_THROW(x) throw x +#endif +#else +#define FMT_THROW(x) \ + do { \ + static_cast(sizeof(x)); \ + assert(false); \ + } while (false); +#endif #endif #ifndef FMT_USE_USER_DEFINED_LITERALS // For Intel's compiler and NVIDIA's compiler both it and the system gcc/msc // must support UDLs. -# if (FMT_HAS_FEATURE(cxx_user_literals) || \ - FMT_GCC_VERSION >= 407 || FMT_MSC_VER >= 1900) && \ - (!(FMT_ICC_VERSION || FMT_CUDA_VERSION) || \ - FMT_ICC_VERSION >= 1500 || FMT_CUDA_VERSION >= 700) -# define FMT_USE_USER_DEFINED_LITERALS 1 -# else -# define FMT_USE_USER_DEFINED_LITERALS 0 -# endif +#if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \ + FMT_MSC_VER >= 1900) && \ + (!(FMT_ICC_VERSION || FMT_CUDA_VERSION) || FMT_ICC_VERSION >= 1500 || \ + FMT_CUDA_VERSION >= 700) +#define FMT_USE_USER_DEFINED_LITERALS 1 +#else +#define FMT_USE_USER_DEFINED_LITERALS 0 +#endif #endif // EDG C++ Front End based compilers (icc, nvcc) do not currently support UDL // templates. -#if FMT_USE_USER_DEFINED_LITERALS && \ - FMT_ICC_VERSION == 0 && \ - FMT_CUDA_VERSION == 0 && \ - ((FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L) || \ - (defined(FMT_CLANG_VERSION) && FMT_CLANG_VERSION >= 304)) -# define FMT_UDL_TEMPLATE 1 +#if FMT_USE_USER_DEFINED_LITERALS && FMT_ICC_VERSION == 0 && \ + FMT_CUDA_VERSION == 0 && \ + ((FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L) || \ + (defined(FMT_CLANG_VERSION) && FMT_CLANG_VERSION >= 304)) +#define FMT_UDL_TEMPLATE 1 #else -# define FMT_UDL_TEMPLATE 0 +#define FMT_UDL_TEMPLATE 0 #endif #ifndef FMT_USE_EXTERN_TEMPLATES -# ifndef FMT_HEADER_ONLY -# define FMT_USE_EXTERN_TEMPLATES \ - ((FMT_CLANG_VERSION >= 209 && __cplusplus >= 201103L) || \ - (FMT_GCC_VERSION >= 303 && FMT_HAS_GXX_CXX11)) -# else -# define FMT_USE_EXTERN_TEMPLATES 0 -# endif +#ifndef FMT_HEADER_ONLY +#define FMT_USE_EXTERN_TEMPLATES \ + ((FMT_CLANG_VERSION >= 209 && __cplusplus >= 201103L) || \ + (FMT_GCC_VERSION >= 303 && FMT_HAS_GXX_CXX11)) +#else +#define FMT_USE_EXTERN_TEMPLATES 0 +#endif #endif #if FMT_HAS_GXX_CXX11 || FMT_HAS_FEATURE(cxx_trailing_return) || \ FMT_MSC_VER >= 1600 -# define FMT_USE_TRAILING_RETURN 1 +#define FMT_USE_TRAILING_RETURN 1 #else -# define FMT_USE_TRAILING_RETURN 0 +#define FMT_USE_TRAILING_RETURN 0 #endif #ifndef FMT_USE_GRISU -# define FMT_USE_GRISU 0 +#define FMT_USE_GRISU 0 //# define FMT_USE_GRISU std::numeric_limits::is_iec559 #endif // __builtin_clz is broken in clang with Microsoft CodeGen: // https://github.com/fmtlib/fmt/issues/519 #ifndef _MSC_VER -# if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clz) -# define FMT_BUILTIN_CLZ(n) __builtin_clz(n) -# endif +#if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clz) +#define FMT_BUILTIN_CLZ(n) __builtin_clz(n) +#endif -# if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clzll) -# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n) -# endif +#if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clzll) +#define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n) +#endif #endif // Some compilers masquerade as both MSVC and GCC-likes or otherwise support // __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the // MSVC intrinsics if the clz and clzll builtins are not available. #if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && !defined(_MANAGED) -# include // _BitScanReverse, _BitScanReverse64 +#include // _BitScanReverse, _BitScanReverse64 FMT_BEGIN_NAMESPACE namespace internal { // Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning. -# ifndef __clang__ -# pragma intrinsic(_BitScanReverse) -# endif +#ifndef __clang__ +#pragma intrinsic(_BitScanReverse) +#endif inline uint32_t clz(uint32_t x) { unsigned long r = 0; _BitScanReverse(&r, x); @@ -198,37 +201,36 @@ inline uint32_t clz(uint32_t x) { // Static analysis complains about using uninitialized data // "r", but the only way that can happen is if "x" is 0, // which the callers guarantee to not happen. -# pragma warning(suppress: 6102) +#pragma warning(suppress : 6102) return 31 - r; } -# define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n) +#define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n) -# if defined(_WIN64) && !defined(__clang__) -# pragma intrinsic(_BitScanReverse64) -# endif +#if defined(_WIN64) && !defined(__clang__) +#pragma intrinsic(_BitScanReverse64) +#endif inline uint32_t clzll(uint64_t x) { unsigned long r = 0; -# ifdef _WIN64 +#ifdef _WIN64 _BitScanReverse64(&r, x); -# else +#else // Scan the high 32 bits. - if (_BitScanReverse(&r, static_cast(x >> 32))) - return 63 - (r + 32); + if (_BitScanReverse(&r, static_cast(x >> 32))) return 63 - (r + 32); // Scan the low 32 bits. _BitScanReverse(&r, static_cast(x)); -# endif +#endif assert(x != 0); // Static analysis complains about using uninitialized data // "r", but the only way that can happen is if "x" is 0, // which the callers guarantee to not happen. -# pragma warning(suppress: 6102) +#pragma warning(suppress : 6102) return 63 - r; } -# define FMT_BUILTIN_CLZLL(n) fmt::internal::clzll(n) -} +#define FMT_BUILTIN_CLZLL(n) fmt::internal::clzll(n) +} // namespace internal FMT_END_NAMESPACE #endif @@ -239,7 +241,7 @@ namespace internal { // undefined behavior (e.g. due to type aliasing). // Example: uint64_t d = bit_cast(2.718); template -inline Dest bit_cast(const Source& source) { +inline Dest bit_cast(const Source &source) { static_assert(sizeof(Dest) == sizeof(Source), "size mismatch"); Dest dest; std::memcpy(&dest, &source, sizeof(dest)); @@ -252,17 +254,25 @@ FMT_CONSTEXPR auto begin(const C &c) -> decltype(c.begin()) { return c.begin(); } template -FMT_CONSTEXPR T *begin(T (&array)[N]) FMT_NOEXCEPT { return array; } +FMT_CONSTEXPR T *begin(T (&array)[N]) FMT_NOEXCEPT { + return array; +} template -FMT_CONSTEXPR auto end(const C &c) -> decltype(c.end()) { return c.end(); } +FMT_CONSTEXPR auto end(const C &c) -> decltype(c.end()) { + return c.end(); +} template -FMT_CONSTEXPR T *end(T (&array)[N]) FMT_NOEXCEPT { return array + N; } +FMT_CONSTEXPR T *end(T (&array)[N]) FMT_NOEXCEPT { + return array + N; +} // For std::result_of in gcc 4.4. template struct function { template - struct result { typedef Result type; }; + struct result { + typedef Result type; + }; }; struct dummy_int { @@ -279,7 +289,7 @@ inline dummy_int isnan(...) { return dummy_int(); } inline dummy_int _isnan(...) { return dummy_int(); } template -typename Allocator::value_type *allocate(Allocator& alloc, std::size_t n) { +typename Allocator::value_type *allocate(Allocator &alloc, std::size_t n) { #if __cplusplus >= 201103L || FMT_MSC_VER >= 1700 return std::allocator_traits::allocate(alloc, n); #else @@ -290,7 +300,9 @@ typename Allocator::value_type *allocate(Allocator& alloc, std::size_t n) { // A helper function to suppress bogus "conditional expression is constant" // warnings. template -inline T const_check(T value) { return value; } +inline T const_check(T value) { + return value; +} } // namespace internal FMT_END_NAMESPACE @@ -300,8 +312,8 @@ namespace std { // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48891 // and the same for isnan. template <> -class numeric_limits : - public std::numeric_limits { +class numeric_limits + : public std::numeric_limits { public: // Portable version of isinf. template @@ -342,20 +354,21 @@ class output_range { typedef OutputIt iterator; typedef T value_type; - explicit output_range(OutputIt it): it_(it) {} + explicit output_range(OutputIt it) : it_(it) {} OutputIt begin() const { return it_; } }; // A range where begin() returns back_insert_iterator. template -class back_insert_range: - public output_range> { +class back_insert_range + : public output_range> { typedef output_range> base; + public: typedef typename Container::value_type value_type; - back_insert_range(Container &c): base(std::back_inserter(c)) {} - back_insert_range(typename base::iterator it): base(it) {} + back_insert_range(Container &c) : base(std::back_inserter(c)) {} + back_insert_range(typename base::iterator it) : base(it) {} }; typedef basic_writer> writer; @@ -364,29 +377,35 @@ typedef basic_writer> wwriter; /** A formatting error such as invalid format string. */ class format_error : public std::runtime_error { public: - explicit format_error(const char *message) - : std::runtime_error(message) {} + explicit format_error(const char *message) : std::runtime_error(message) {} explicit format_error(const std::string &message) - : std::runtime_error(message) {} + : std::runtime_error(message) {} }; namespace internal { #if FMT_SECURE_SCL template -struct checked { typedef stdext::checked_array_iterator type; }; +struct checked { + typedef stdext::checked_array_iterator type; +}; // Make a checked iterator to avoid warnings on MSVC. template -inline stdext::checked_array_iterator make_checked(T *p, std::size_t size) { +inline stdext::checked_array_iterator make_checked(T *p, + std::size_t size) { return {p, size}; } #else template -struct checked { typedef T *type; }; +struct checked { + typedef T *type; +}; template -inline T *make_checked(T *p, std::size_t) { return p; } +inline T *make_checked(T *p, std::size_t) { + return p; +} #endif template @@ -404,7 +423,7 @@ void basic_buffer::append(const U *begin, const U *end) { // type in this mode. If this is the case __cpp_char8_t will be defined. #if !defined(__cpp_char8_t) // A UTF-8 code unit type. -enum char8_t: unsigned char {}; +enum char8_t : unsigned char {}; #endif // A UTF-8 string view. @@ -412,10 +431,11 @@ class u8string_view : public basic_string_view { public: typedef char8_t char_type; - u8string_view(const char *s): - basic_string_view(reinterpret_cast(s)) {} - u8string_view(const char *s, size_t count) FMT_NOEXCEPT: - basic_string_view(reinterpret_cast(s), count) {} + u8string_view(const char *s) + : basic_string_view(reinterpret_cast(s)) {} + u8string_view(const char *s, size_t count) FMT_NOEXCEPT + : basic_string_view(reinterpret_cast(s), + count) {} }; #if FMT_USE_USER_DEFINED_LITERALS @@ -423,7 +443,7 @@ inline namespace literals { inline u8string_view operator"" _u(const char *s, std::size_t n) { return {s, n}; } -} +} // namespace literals #endif // The number of characters to store in the basic_memory_buffer object itself @@ -460,14 +480,15 @@ enum { inline_buffer_size = 500 }; \endrst */ template > -class basic_memory_buffer: private Allocator, public internal::basic_buffer { + typename Allocator = std::allocator> +class basic_memory_buffer : private Allocator, + public internal::basic_buffer { private: T store_[SIZE]; // Deallocate memory allocated by the buffer. void deallocate() { - T* data = this->data(); + T *data = this->data(); if (data != store_) Allocator::deallocate(data, this->capacity()); } @@ -489,7 +510,7 @@ class basic_memory_buffer: private Allocator, public internal::basic_buffer { void move(basic_memory_buffer &other) { Allocator &this_alloc = *this, &other_alloc = other; this_alloc = std::move(other_alloc); - T* data = other.data(); + T *data = other.data(); std::size_t size = other.size(), capacity = other.capacity(); if (data == other.store_) { this->set(store_, capacity); @@ -511,9 +532,7 @@ class basic_memory_buffer: private Allocator, public internal::basic_buffer { of the other object to it. \endrst */ - basic_memory_buffer(basic_memory_buffer &&other) { - move(other); - } + basic_memory_buffer(basic_memory_buffer &&other) { move(other); } /** \rst @@ -535,8 +554,7 @@ template void basic_memory_buffer::grow(std::size_t size) { std::size_t old_capacity = this->capacity(); std::size_t new_capacity = old_capacity + old_capacity / 2; - if (size > new_capacity) - new_capacity = size; + if (size > new_capacity) new_capacity = size; T *old_data = this->data(); T *new_data = internal::allocate(*this, new_capacity); // The following code doesn't throw, so the raw pointer above doesn't leak. @@ -546,8 +564,7 @@ void basic_memory_buffer::grow(std::size_t size) { // deallocate must not throw according to the standard, but even if it does, // the buffer already uses the new storage and will deallocate it in // destructor. - if (old_data != store_) - Allocator::deallocate(old_data, old_capacity); + if (old_data != store_) Allocator::deallocate(old_data, old_capacity); } typedef basic_memory_buffer memory_buffer; @@ -563,37 +580,40 @@ struct char_traits { // Formats a floating-point number. template FMT_API static int format_float(char *buffer, std::size_t size, - const char *format, int precision, T value); + const char *format, int precision, T value); }; template <> struct char_traits { template FMT_API static int format_float(wchar_t *buffer, std::size_t size, - const wchar_t *format, int precision, T value); + const wchar_t *format, int precision, + T value); }; #if FMT_USE_EXTERN_TEMPLATES -extern template int char_traits::format_float( - char *buffer, std::size_t size, const char* format, int precision, - double value); +extern template int char_traits::format_float(char *buffer, + std::size_t size, + const char *format, + int precision, + double value); extern template int char_traits::format_float( - char *buffer, std::size_t size, const char* format, int precision, + char *buffer, std::size_t size, const char *format, int precision, long double value); extern template int char_traits::format_float( - wchar_t *buffer, std::size_t size, const wchar_t* format, int precision, + wchar_t *buffer, std::size_t size, const wchar_t *format, int precision, double value); extern template int char_traits::format_float( - wchar_t *buffer, std::size_t size, const wchar_t* format, int precision, + wchar_t *buffer, std::size_t size, const wchar_t *format, int precision, long double value); #endif template inline typename std::enable_if< - is_contiguous::value, - typename checked::type>::type - reserve(std::back_insert_iterator &it, std::size_t n) { + is_contiguous::value, + typename checked::type>::type +reserve(std::back_insert_iterator &it, std::size_t n) { Container &c = internal::get_container(it); std::size_t size = c.size(); c.resize(size + n); @@ -601,7 +621,9 @@ inline typename std::enable_if< } template -inline Iterator &reserve(Iterator &it, std::size_t) { return it; } +inline Iterator &reserve(Iterator &it, std::size_t) { + return it; +} template class null_terminating_iterator; @@ -621,15 +643,15 @@ class counting_iterator { typedef std::output_iterator_tag iterator_category; typedef T value_type; typedef std::ptrdiff_t difference_type; - typedef T* pointer; - typedef T& reference; + typedef T *pointer; + typedef T &reference; typedef counting_iterator _Unchecked_type; // Mark iterator as checked. - counting_iterator(): count_(0) {} + counting_iterator() : count_(0) {} std::size_t count() const { return count_; } - counting_iterator& operator++() { + counting_iterator &operator++() { ++count_; return *this; } @@ -651,14 +673,15 @@ class truncating_iterator_base { std::size_t count_; truncating_iterator_base(OutputIt out, std::size_t limit) - : out_(out), limit_(limit), count_(0) {} + : out_(out), limit_(limit), count_(0) {} public: typedef std::output_iterator_tag iterator_category; typedef void difference_type; typedef void pointer; typedef void reference; - typedef truncating_iterator_base _Unchecked_type; // Mark iterator as checked. + typedef truncating_iterator_base + _Unchecked_type; // Mark iterator as checked. OutputIt base() const { return out_; } std::size_t count() const { return count_; } @@ -666,13 +689,14 @@ class truncating_iterator_base { // An output iterator that truncates the output and counts the number of objects // written to it. -template ::value_type>::type> +template ::value_type>::type> class truncating_iterator; template -class truncating_iterator: - public truncating_iterator_base { +class truncating_iterator + : public truncating_iterator_base { typedef std::iterator_traits traits; mutable typename traits::value_type blackhole_; @@ -681,11 +705,10 @@ class truncating_iterator: typedef typename traits::value_type value_type; truncating_iterator(OutputIt out, std::size_t limit) - : truncating_iterator_base(out, limit) {} + : truncating_iterator_base(out, limit) {} - truncating_iterator& operator++() { - if (this->count_++ < this->limit_) - ++this->out_; + truncating_iterator &operator++() { + if (this->count_++ < this->limit_) ++this->out_; return *this; } @@ -695,41 +718,42 @@ class truncating_iterator: return it; } - value_type& operator*() const { + value_type &operator*() const { return this->count_ < this->limit_ ? *this->out_ : blackhole_; } }; template -class truncating_iterator: - public truncating_iterator_base { +class truncating_iterator + : public truncating_iterator_base { public: typedef typename OutputIt::container_type::value_type value_type; truncating_iterator(OutputIt out, std::size_t limit) - : truncating_iterator_base(out, limit) {} + : truncating_iterator_base(out, limit) {} - truncating_iterator& operator=(value_type val) { - if (this->count_++ < this->limit_) - this->out_ = val; + truncating_iterator &operator=(value_type val) { + if (this->count_++ < this->limit_) this->out_ = val; return *this; } - truncating_iterator& operator++() { return *this; } - truncating_iterator& operator++(int) { return *this; } - truncating_iterator& operator*() { return *this; } + truncating_iterator &operator++() { return *this; } + truncating_iterator &operator++(int) { return *this; } + truncating_iterator &operator*() { return *this; } }; // Returns true if value is negative, false otherwise. // Same as (value < 0) but doesn't produce warnings if T is an unsigned type. template -FMT_CONSTEXPR typename std::enable_if< - std::numeric_limits::is_signed, bool>::type is_negative(T value) { +FMT_CONSTEXPR + typename std::enable_if::is_signed, bool>::type + is_negative(T value) { return value < 0; } template -FMT_CONSTEXPR typename std::enable_if< - !std::numeric_limits::is_signed, bool>::type is_negative(T) { +FMT_CONSTEXPR + typename std::enable_if::is_signed, bool>::type + is_negative(T) { return false; } @@ -737,8 +761,8 @@ template struct int_traits { // Smallest of uint32_t and uint64_t that is large enough to represent // all values of T. - typedef typename std::conditional< - std::numeric_limits::digits <= 32, uint32_t, uint64_t>::type main_type; + typedef typename std::conditional::digits <= 32, + uint32_t, uint64_t>::type main_type; }; // Static data is placed in this class template to allow header-only @@ -791,7 +815,9 @@ inline int count_digits(uint64_t n) { #endif template -inline size_t count_code_points(basic_string_view s) { return s.size(); } +inline size_t count_code_points(basic_string_view s) { + return s.size(); +} // Counts the number of code points in a UTF-8 string. FMT_API size_t count_code_points(basic_string_view s); @@ -799,29 +825,30 @@ FMT_API size_t count_code_points(basic_string_view s); inline char8_t to_char8_t(char c) { return static_cast(c); } template -struct needs_conversion: std::integral_constant::value_type, char>::value && - std::is_same::value> {}; +struct needs_conversion + : std::integral_constant< + bool, std::is_same::value_type, + char>::value && + std::is_same::value> {}; template -typename std::enable_if< - !needs_conversion::value, OutputIt>::type - copy_str(InputIt begin, InputIt end, OutputIt it) { +typename std::enable_if::value, + OutputIt>::type +copy_str(InputIt begin, InputIt end, OutputIt it) { return std::copy(begin, end, it); } template -typename std::enable_if< - needs_conversion::value, OutputIt>::type - copy_str(InputIt begin, InputIt end, OutputIt it) { +typename std::enable_if::value, + OutputIt>::type +copy_str(InputIt begin, InputIt end, OutputIt it) { return std::transform(begin, end, it, to_char8_t); } #if FMT_HAS_CPP_ATTRIBUTE(always_inline) -# define FMT_ALWAYS_INLINE __attribute__((always_inline)) +#define FMT_ALWAYS_INLINE __attribute__((always_inline)) #else -# define FMT_ALWAYS_INLINE +#define FMT_ALWAYS_INLINE #endif template @@ -855,7 +882,8 @@ class decimal_formatter { public: explicit decimal_formatter(char *buf) : buffer_(buf) {} - template char *on(uint32_t u) { + template + char *on(uint32_t u) { if (N == 0) { *buffer_ = static_cast(u) + '0'; } else if (N == 1) { @@ -865,8 +893,8 @@ class decimal_formatter { // https://github.com/jeaiii/itoa unsigned n = N - 1; unsigned a = n / 5 * n * 53 / 16; - uint64_t t = ((1ULL << (32 + a)) / - data::ZERO_OR_POWERS_OF_10_32[n] + 1 - n / 9); + uint64_t t = + ((1ULL << (32 + a)) / data::ZERO_OR_POWERS_OF_10_32[n] + 1 - n / 9); t = ((t * u) >> a) + n / 5 * 4; write_pair(0, t >> 32); for (unsigned i = 2; i < N; i += 2) { @@ -874,8 +902,8 @@ class decimal_formatter { write_pair(i, t >> 32); } if (N % 2 == 0) { - buffer_[N] = static_cast( - (10ULL * static_cast(t)) >> 32) + '0'; + buffer_[N] = + static_cast((10ULL * static_cast(t)) >> 32) + '0'; } } return buffer_ += N + 1; @@ -887,7 +915,8 @@ class decimal_formatter_null : public decimal_formatter { public: explicit decimal_formatter_null(char *buf) : decimal_formatter(buf) {} - template char *on(uint32_t u) { + template + char *on(uint32_t u) { char *buf = decimal_formatter::on(u); *buf = '\0'; return buf; @@ -925,11 +954,10 @@ class add_thousands_sep { typedef Char char_type; explicit add_thousands_sep(basic_string_view sep) - : sep_(sep), digit_index_(0) {} + : sep_(sep), digit_index_(0) {} void operator()(Char *&buffer) { - if (++digit_index_ % 3 != 0) - return; + if (++digit_index_ % 3 != 0) return; buffer -= sep_.size(); std::uninitialized_copy(sep_.data(), sep_.data() + sep_.size(), internal::make_checked(buffer, sep_.size())); @@ -984,8 +1012,8 @@ inline Char *format_decimal(Char *buffer, UInt value, int num_digits, template -inline Iterator format_decimal( - Iterator out, UInt value, int num_digits, ThousandsSep sep) { +inline Iterator format_decimal(Iterator out, UInt value, int num_digits, + ThousandsSep sep) { FMT_ASSERT(num_digits >= 0, "invalid digit count"); typedef typename ThousandsSep::char_type char_type; // Buffer should be large enough to hold all digits (<= digits10 + 1). @@ -1016,8 +1044,7 @@ inline Char *format_uint(Char *buffer, UInt value, int num_digits, } template -inline It format_uint(It out, UInt value, int num_digits, - bool upper = false) { +inline It format_uint(It out, UInt value, int num_digits, bool upper = false) { // Buffer should be large enough to hold all digits (digits / BASE_BITS + 1) // and null. char buffer[std::numeric_limits::digits / BASE_BITS + 2]; @@ -1026,9 +1053,9 @@ inline It format_uint(It out, UInt value, int num_digits, } #ifndef _WIN32 -# define FMT_USE_WINDOWS_H 0 +#define FMT_USE_WINDOWS_H 0 #elif !defined(FMT_USE_WINDOWS_H) -# define FMT_USE_WINDOWS_H 1 +#define FMT_USE_WINDOWS_H 1 #endif // Define FMT_USE_WINDOWS_H to 0 to disable use of windows.h. @@ -1077,7 +1104,11 @@ struct null {}; } // namespace internal enum alignment { - ALIGN_DEFAULT, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_NUMERIC + ALIGN_DEFAULT, + ALIGN_LEFT, + ALIGN_RIGHT, + ALIGN_CENTER, + ALIGN_NUMERIC }; // Flags. @@ -1116,8 +1147,7 @@ typedef basic_format_specs format_specs; template FMT_CONSTEXPR unsigned basic_parse_context::next_arg_id() { - if (next_arg_id_ >= 0) - return internal::to_unsigned(next_arg_id_++); + if (next_arg_id_ >= 0) return internal::to_unsigned(next_arg_id_++); on_error("cannot switch from manual to automatic argument indexing"); return 0; } @@ -1128,10 +1158,12 @@ namespace internal { // https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf template FMT_API typename std::enable_if::type - grisu2_format(Double value, buffer &buf, core_format_specs); +grisu2_format(Double value, buffer &buf, core_format_specs); template inline typename std::enable_if::type - grisu2_format(Double, buffer &, core_format_specs) { return false; } +grisu2_format(Double, buffer &, core_format_specs) { + return false; +} template void sprintf_format(Double, internal::buffer &, core_format_specs); @@ -1139,50 +1171,58 @@ void sprintf_format(Double, internal::buffer &, core_format_specs); template FMT_CONSTEXPR void handle_int_type_spec(char spec, Handler &&handler) { switch (spec) { - case 0: case 'd': - handler.on_dec(); - break; - case 'x': case 'X': - handler.on_hex(); - break; - case 'b': case 'B': - handler.on_bin(); - break; - case 'o': - handler.on_oct(); - break; - case 'n': - handler.on_num(); - break; - default: - handler.on_error(); + case 0: + case 'd': + handler.on_dec(); + break; + case 'x': + case 'X': + handler.on_hex(); + break; + case 'b': + case 'B': + handler.on_bin(); + break; + case 'o': + handler.on_oct(); + break; + case 'n': + handler.on_num(); + break; + default: + handler.on_error(); } } template FMT_CONSTEXPR void handle_float_type_spec(char spec, Handler &&handler) { switch (spec) { - case 0: case 'g': case 'G': - handler.on_general(); - break; - case 'e': case 'E': - handler.on_exp(); - break; - case 'f': case 'F': - handler.on_fixed(); - break; - case 'a': case 'A': - handler.on_hex(); - break; - default: - handler.on_error(); - break; + case 0: + case 'g': + case 'G': + handler.on_general(); + break; + case 'e': + case 'E': + handler.on_exp(); + break; + case 'f': + case 'F': + handler.on_fixed(); + break; + case 'a': + case 'A': + handler.on_hex(); + break; + default: + handler.on_error(); + break; } } template -FMT_CONSTEXPR void handle_char_specs( - const basic_format_specs *specs, Handler &&handler) { +FMT_CONSTEXPR void handle_char_specs(const basic_format_specs *specs, + Handler &&handler) { if (!specs) return handler.on_char(); if (specs->type && specs->type != 'c') return handler.on_int(); if (specs->align() == ALIGN_NUMERIC || specs->flags != 0) @@ -1202,14 +1242,12 @@ FMT_CONSTEXPR void handle_cstring_type_spec(Char spec, Handler &&handler) { template FMT_CONSTEXPR void check_string_type_spec(Char spec, ErrorHandler &&eh) { - if (spec != 0 && spec != 's') - eh.on_error("invalid type specifier"); + if (spec != 0 && spec != 's') eh.on_error("invalid type specifier"); } template FMT_CONSTEXPR void check_pointer_type_spec(Char spec, ErrorHandler &&eh) { - if (spec != 0 && spec != 'p') - eh.on_error("invalid type specifier"); + if (spec != 0 && spec != 'p') eh.on_error("invalid type specifier"); } template @@ -1232,7 +1270,7 @@ template class float_type_checker : private ErrorHandler { public: FMT_CONSTEXPR explicit float_type_checker(ErrorHandler eh) - : ErrorHandler(eh) {} + : ErrorHandler(eh) {} FMT_CONSTEXPR void on_general() {} FMT_CONSTEXPR void on_exp() {} @@ -1251,7 +1289,7 @@ class char_specs_checker : public ErrorHandler { public: FMT_CONSTEXPR char_specs_checker(char type, ErrorHandler eh) - : ErrorHandler(eh), type_(type) {} + : ErrorHandler(eh), type_(type) {} FMT_CONSTEXPR void on_int() { handle_int_type_spec(type_, int_type_checker(*this)); @@ -1263,7 +1301,7 @@ template class cstring_type_checker : public ErrorHandler { public: FMT_CONSTEXPR explicit cstring_type_checker(ErrorHandler eh) - : ErrorHandler(eh) {} + : ErrorHandler(eh) {} FMT_CONSTEXPR void on_string() {} FMT_CONSTEXPR void on_pointer() {} @@ -1271,11 +1309,10 @@ class cstring_type_checker : public ErrorHandler { template void arg_map::init(const basic_format_args &args) { - if (map_) - return; + if (map_) return; map_ = new entry[args.max_size()]; if (args.is_packed()) { - for (unsigned i = 0;/*nothing*/; ++i) { + for (unsigned i = 0; /*nothing*/; ++i) { internal::type arg_type = args.type(i); switch (arg_type) { case internal::none_type: @@ -1284,11 +1321,11 @@ void arg_map::init(const basic_format_args &args) { push_back(args.values_[i]); break; default: - break; // Do nothing. + break; // Do nothing. } } } - for (unsigned i = 0; ; ++i) { + for (unsigned i = 0;; ++i) { switch (args.args_[i].type_) { case internal::none_type: return; @@ -1296,7 +1333,7 @@ void arg_map::init(const basic_format_args &args) { push_back(args.args_[i].value_); break; default: - break; // Do nothing. + break; // Do nothing. } } } @@ -1320,7 +1357,9 @@ class arg_formatter_base { size_t width() const { return 1; } template - void operator()(It &&it) const { *it++ = value; } + void operator()(It &&it) const { + *it++ = value; + } }; void write_char(char_type value) { @@ -1348,8 +1387,7 @@ class arg_formatter_base { } void write(const char_type *value) { - if (!value) - FMT_THROW(format_error("string pointer is null")); + if (!value) FMT_THROW(format_error("string pointer is null")); auto length = std::char_traits::length(value); basic_string_view sv(value, length); specs_ ? writer_.write(sv, *specs_) : writer_.write(sv); @@ -1357,7 +1395,7 @@ class arg_formatter_base { public: arg_formatter_base(Range r, format_specs *s, locale_ref loc) - : writer_(r, loc), specs_(s) {} + : writer_(r, loc), specs_(s) {} iterator operator()(monostate) { FMT_ASSERT(false, "invalid argument type"); @@ -1365,18 +1403,18 @@ class arg_formatter_base { } template - typename std::enable_if< - std::is_integral::value || std::is_same::value, - iterator>::type operator()(T value) { + typename std::enable_if::value || + std::is_same::value, + iterator>::type + operator()(T value) { // MSVC2013 fails to compile separate overloads for bool and char_type so // use std::is_same instead. if (std::is_same::value) { - if (specs_ && specs_->type) - return (*this)(value ? 1 : 0); + if (specs_ && specs_->type) return (*this)(value ? 1 : 0); write(value != 0); } else if (std::is_same::value) { internal::handle_char_specs( - specs_, char_spec_handler(*this, static_cast(value))); + specs_, char_spec_handler(*this, static_cast(value))); } else { specs_ ? writer_.write_int(value, *specs_) : writer_.write(value); } @@ -1385,7 +1423,7 @@ class arg_formatter_base { template typename std::enable_if::value, iterator>::type - operator()(T value) { + operator()(T value) { writer_.write_double(value, specs_ ? *specs_ : format_specs()); return out(); } @@ -1394,8 +1432,8 @@ class arg_formatter_base { arg_formatter_base &formatter; char_type value; - char_spec_handler(arg_formatter_base& f, char_type val) - : formatter(f), value(val) {} + char_spec_handler(arg_formatter_base &f, char_type val) + : formatter(f), value(val) {} void on_int() { if (formatter.specs_) @@ -1411,7 +1449,7 @@ class arg_formatter_base { const char_type *value; cstring_spec_handler(arg_formatter_base &f, const char_type *val) - : formatter(f), value(val) {} + : formatter(f), value(val) {} void on_string() { formatter.write(value); } void on_pointer() { formatter.write_pointer(value); } @@ -1419,15 +1457,14 @@ class arg_formatter_base { iterator operator()(const char_type *value) { if (!specs_) return write(value), out(); - internal::handle_cstring_type_spec( - specs_->type, cstring_spec_handler(*this, value)); + internal::handle_cstring_type_spec(specs_->type, + cstring_spec_handler(*this, value)); return out(); } iterator operator()(basic_string_view value) { if (specs_) { - internal::check_string_type_spec( - specs_->type, internal::error_handler()); + internal::check_string_type_spec(specs_->type, internal::error_handler()); writer_.write(value, *specs_); } else { writer_.write(value); @@ -1451,8 +1488,9 @@ FMT_CONSTEXPR bool is_name_start(Char c) { // Parses the range [begin, end) as an unsigned integer. This function assumes // that the range is non-empty and the first character is a digit. template -FMT_CONSTEXPR unsigned parse_nonnegative_int( - const Char *&begin, const Char *end, ErrorHandler &&eh) { +FMT_CONSTEXPR unsigned parse_nonnegative_int(const Char *&begin, + const Char *end, + ErrorHandler &&eh) { assert(begin != end && '0' <= *begin && *begin <= '9'); if (*begin == '0') { ++begin; @@ -1471,18 +1509,17 @@ FMT_CONSTEXPR unsigned parse_nonnegative_int( value = value * 10 + unsigned(*begin - '0'); ++begin; } while (begin != end && '0' <= *begin && *begin <= '9'); - if (value > max_int) - eh.on_error("number is too big"); + if (value > max_int) eh.on_error("number is too big"); return value; } template -class custom_formatter: public function { +class custom_formatter : public function { private: Context &ctx_; public: - explicit custom_formatter(Context &ctx): ctx_(ctx) {} + explicit custom_formatter(Context &ctx) : ctx_(ctx) {} bool operator()(typename basic_format_arg::handle h) const { h.format(ctx_); @@ -1490,7 +1527,9 @@ class custom_formatter: public function { } template - bool operator()(T) const { return false; } + bool operator()(T) const { + return false; + } }; template @@ -1502,22 +1541,22 @@ struct is_integer { }; template -class width_checker: public function { +class width_checker : public function { public: explicit FMT_CONSTEXPR width_checker(ErrorHandler &eh) : handler_(eh) {} template FMT_CONSTEXPR - typename std::enable_if< - is_integer::value, unsigned long long>::type operator()(T value) { - if (is_negative(value)) - handler_.on_error("negative width"); + typename std::enable_if::value, unsigned long long>::type + operator()(T value) { + if (is_negative(value)) handler_.on_error("negative width"); return static_cast(value); } template - FMT_CONSTEXPR typename std::enable_if< - !is_integer::value, unsigned long long>::type operator()(T) { + FMT_CONSTEXPR + typename std::enable_if::value, unsigned long long>::type + operator()(T) { handler_.on_error("width is not integer"); return 0; } @@ -1527,21 +1566,22 @@ class width_checker: public function { }; template -class precision_checker: public function { +class precision_checker : public function { public: explicit FMT_CONSTEXPR precision_checker(ErrorHandler &eh) : handler_(eh) {} template - FMT_CONSTEXPR typename std::enable_if< - is_integer::value, unsigned long long>::type operator()(T value) { - if (is_negative(value)) - handler_.on_error("negative precision"); + FMT_CONSTEXPR + typename std::enable_if::value, unsigned long long>::type + operator()(T value) { + if (is_negative(value)) handler_.on_error("negative precision"); return static_cast(value); } template - FMT_CONSTEXPR typename std::enable_if< - !is_integer::value, unsigned long long>::type operator()(T) { + FMT_CONSTEXPR + typename std::enable_if::value, unsigned long long>::type + operator()(T) { handler_.on_error("precision is not integer"); return 0; } @@ -1554,10 +1594,11 @@ class precision_checker: public function { template class specs_setter { public: - explicit FMT_CONSTEXPR specs_setter(basic_format_specs &specs): - specs_(specs) {} + explicit FMT_CONSTEXPR specs_setter(basic_format_specs &specs) + : specs_(specs) {} - FMT_CONSTEXPR specs_setter(const specs_setter &other): specs_(other.specs_) {} + FMT_CONSTEXPR specs_setter(const specs_setter &other) + : specs_(other.specs_) {} FMT_CONSTEXPR void on_align(alignment align) { specs_.align_ = align; } FMT_CONSTEXPR void on_fill(Char fill) { specs_.fill_ = fill; } @@ -1590,15 +1631,14 @@ class specs_setter { template class specs_checker : public Handler { public: - FMT_CONSTEXPR specs_checker(const Handler& handler, internal::type arg_type) - : Handler(handler), arg_type_(arg_type) {} + FMT_CONSTEXPR specs_checker(const Handler &handler, internal::type arg_type) + : Handler(handler), arg_type_(arg_type) {} FMT_CONSTEXPR specs_checker(const specs_checker &other) - : Handler(other), arg_type_(other.arg_type_) {} + : Handler(other), arg_type_(other.arg_type_) {} FMT_CONSTEXPR void on_align(alignment align) { - if (align == ALIGN_NUMERIC) - require_numeric_argument(); + if (align == ALIGN_NUMERIC) require_numeric_argument(); Handler::on_align(align); } @@ -1649,10 +1689,10 @@ class specs_checker : public Handler { internal::type arg_type_; }; -template