├── .gitignore
├── .settings
├── language.settings.xml
├── org.eclipse.cdt.codan.core.prefs
├── org.eclipse.cdt.core.prefs
└── org.eclipse.ltk.core.refactoring.prefs
├── .vscode
├── c_cpp_properties.json
└── tasks.json
├── Documents
├── ER-TFTM035-6_Datasheet.pdf
├── ER-TFTM035-6_Interfacing.pdf
├── FT6236-FT6336-FT6436L-FT6436_Datasheet.pdf
├── ILI9341.pdf
├── ILI9488.pdf
├── ST7789S.pdf
├── ST7789V.pdf
├── STMPE610-ST Microelectronics.pdf
├── STMPE610.pdf
└── XPT2046.pdf
├── Makefile
├── README.md
├── components
├── mkspiffs
│ ├── .travis.yml
│ ├── Makefile.projbuild
│ ├── component.mk
│ └── src
│ │ ├── Makefile
│ │ ├── README.md
│ │ ├── appveyor.yml
│ │ ├── main.cpp
│ │ ├── spiffs
│ │ ├── esp_spiffs.c
│ │ ├── esp_spiffs.h
│ │ ├── spiffs.h
│ │ ├── spiffs_cache.c
│ │ ├── spiffs_check.c
│ │ ├── spiffs_config.h
│ │ ├── spiffs_gc.c
│ │ ├── spiffs_hydrogen.c
│ │ ├── spiffs_nucleus.c
│ │ └── spiffs_nucleus.h
│ │ └── tclap
│ │ ├── Arg.h
│ │ ├── ArgException.h
│ │ ├── ArgTraits.h
│ │ ├── COPYING
│ │ ├── CmdLine.h
│ │ ├── CmdLineInterface.h
│ │ ├── CmdLineOutput.h
│ │ ├── Constraint.h
│ │ ├── DocBookOutput.h
│ │ ├── HelpVisitor.h
│ │ ├── IgnoreRestVisitor.h
│ │ ├── MultiArg.h
│ │ ├── MultiSwitchArg.h
│ │ ├── OptionalUnlabeledTracker.h
│ │ ├── StandardTraits.h
│ │ ├── StdOutput.h
│ │ ├── SwitchArg.h
│ │ ├── UnlabeledMultiArg.h
│ │ ├── UnlabeledValueArg.h
│ │ ├── ValueArg.h
│ │ ├── ValuesConstraint.h
│ │ ├── VersionVisitor.h
│ │ ├── Visitor.h
│ │ ├── XorHandler.h
│ │ └── ZshCompletionOutput.h
├── spidriver
│ ├── component.mk
│ ├── spi_master_lobo.c
│ └── spi_master_lobo.h
├── spiffs
│ ├── component.mk
│ ├── esp_spiffs.c
│ ├── esp_spiffs.h
│ ├── list.c
│ ├── list.h
│ ├── mutex.c
│ ├── mutex.h
│ ├── spiffs.h
│ ├── spiffs_cache.c
│ ├── spiffs_check.c
│ ├── spiffs_config.h
│ ├── spiffs_gc.c
│ ├── spiffs_hydrogen.c
│ ├── spiffs_nucleus.c
│ ├── spiffs_nucleus.h
│ ├── spiffs_vfs.c
│ └── spiffs_vfs.h
├── spiffs_image
│ ├── Makefile.projbuild
│ ├── component.mk
│ ├── image
│ │ ├── fonts
│ │ │ ├── BigFont.fon
│ │ │ ├── DejaVuSans12.fon
│ │ │ ├── DejaVuSans18.fon
│ │ │ ├── DejaVuSans24.fon
│ │ │ ├── DotMatrix_M.fon
│ │ │ ├── Grotesk24x48.fon
│ │ │ ├── SmallFont.fon
│ │ │ ├── Ubuntu.fon
│ │ │ ├── arial_bold.fon
│ │ │ ├── ocrfont.c
│ │ │ └── swiss721_outline.fon
│ │ ├── images
│ │ │ ├── test1.jpg
│ │ │ ├── test2.jpg
│ │ │ ├── test3.jpg
│ │ │ ├── test4.jpg
│ │ │ └── tiger.bmp
│ │ └── spiffs.info
│ └── spiffs_image.img
└── tft
│ ├── DefaultFont.c
│ ├── DejaVuSans18.c
│ ├── DejaVuSans24.c
│ ├── SmallFont.c
│ ├── Ubuntu16.c
│ ├── comic24.c
│ ├── component.mk
│ ├── def_small.c
│ ├── minya24.c
│ ├── stmpe610.h
│ ├── tft.c
│ ├── tft.h
│ ├── tftspi.c
│ ├── tftspi.h
│ └── tooney32.c
├── main
├── Kconfig.projbuild
├── component.mk
└── tft_demo.c
├── partitions_example.csv
├── sdkconfig.defaults
└── tools
├── DejaVuSans.ttf
├── Vera.ttf
├── def_small.c
├── dejavu.c
├── dejavuX.c
├── dejavuY.c
├── msvcp71.dll
├── msvcr71.dll
├── readme.txt
├── ttf2c_vc2003.exe
└── vera.c
/.gitignore:
--------------------------------------------------------------------------------
1 | .config
2 | *.o
3 | *.pyc
4 | *.a
5 | *.d
6 |
7 | # gtags
8 | GTAGS
9 | GRTAGS
10 | GPATH
11 |
12 | # emacs
13 | .dir-locals.el
14 |
15 | # emacs temp file suffixes
16 | *~
17 | .#*
18 | \#*#
19 |
20 | sdkconfig
21 | sdkconfig.old
22 | sdkconfig.lobo
23 | .cproject
24 | .project
25 | .settings
26 | BUILD
27 | PBUILD
28 | build/
29 | temp/
30 | local/
31 | *.dis
32 | *.elf
33 | *.map
34 | **/.DS_Store
35 |
--------------------------------------------------------------------------------
/.settings/language.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.cdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/ESP_IDF/delimiter=\:
3 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/ESP_IDF/operation=replace
4 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/ESP_IDF/value=/home/LoBo2_Razno/ESP32/esp-idf
5 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/IDF_PATH/delimiter=\:
6 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/IDF_PATH/operation=append
7 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/IDF_PATH/value=/home/LoBo2_Razno/ESP32/esp-idf
8 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/PATH/delimiter=\:
9 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/PATH/operation=replace
10 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/PATH/value=/bin\:/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/usr/games\:/usr/local/games\:/snap/bin\:/usr/lib/jvm/java-8-oracle/bin\:/usr/lib/jvm/java-8-oracle/db/bin\:/usr/lib/jvm/java-8-oracle/jre/bin\:/home/LoBo2_Razno/ESP32/xtensa-esp32-elf/bin
11 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/append=true
12 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617.1047447828/appendContributed=true
13 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617/IDF_PATH/delimiter=\:
14 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617/IDF_PATH/operation=append
15 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617/IDF_PATH/value=/home/LoBo2_Razno/ESP32/esp-idf
16 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617/PATH/delimiter=\:
17 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617/PATH/operation=replace
18 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617/PATH/value=/home/LoBo2_Razno/ESP32/xtensa-esp32-elf/bin\:/bin\:/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/usr/lib/jvm/java-8-oracle/bin\:/usr/lib/jvm/java-8-oracle/db/bin\:/usr/lib/jvm/java-8-oracle/jre/bin
19 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617/append=true
20 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.2062137617/appendContributed=true
21 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/IDF_PATH/delimiter=\:
22 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/IDF_PATH/operation=replace
23 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/IDF_PATH/value=/Users/jaumeolivepetrus/esp-idf
24 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/PATH/delimiter=\:
25 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/PATH/operation=replace
26 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/PATH/value=/usr/local/xtensa-esp32-elf/bin\:/bin\:/usr/bin\:/usr/sbin\:/sbin
27 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/append=true
28 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/appendContributed=true
29 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/v/delimiter=\:
30 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/v/operation=append
31 | environment/project/cdt.managedbuild.toolchain.gnu.cross.base.458462299/v/value=1
32 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.ltk.core.refactoring.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
3 |
--------------------------------------------------------------------------------
/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "Mac",
5 | "includePath": [
6 | "/usr/include",
7 | "/usr/local/include",
8 | "${workspaceRoot}"
9 | ],
10 | "defines": [],
11 | "intelliSenseMode": "clang-x64",
12 | "browse": {
13 | "path": [
14 | "/usr/include",
15 | "/usr/local/include",
16 | "${workspaceRoot}"
17 | ],
18 | "limitSymbolsToIncludedHeaders": true,
19 | "databaseFilename": ""
20 | },
21 | "macFrameworkPath": [
22 | "/System/Library/Frameworks",
23 | "/Library/Frameworks"
24 | ]
25 | },
26 | {
27 | "name": "Linux",
28 | "includePath": [
29 | "/home/LoBo2_Razno/ESP32/esp-idf/components",
30 | "/home/LoBo2_Razno/ESP32/esp-idf/components/driver/include",
31 | "/home/LoBo2_Razno/ESP32/esp-idf/components/newlib/include",
32 | "/home/LoBo2_Razno/ESP32/esp-idf/components/freertos/include",
33 | "/home/LoBo2_Razno/ESP32/esp-idf/components/esp32/include",
34 | "/home/LoBo2_Razno/ESP32/esp-idf/components/log/include",
35 | "/home/LoBo2_Razno/ESP32/esp-idf/components/nvs_flash/include",
36 | "/home/LoBo2_Razno/ESP32/esp-idf/components/heap/include",
37 | "/home/LoBo2_Razno/ESP32/esp-idf/components/tcpip_adapter/include",
38 | "/home/LoBo2_Razno/ESP32/esp-idf/components/soc/include",
39 | "/home/LoBo2_Razno/ESP32/esp-idf/components/lwip/include/lwip",
40 | "/home/LoBo2_Razno/ESP32/esp-idf/components/lwip/include/lwip/port",
41 | "/home/LoBo2_Razno/ESP32/esp-idf/components/soc/esp32/include",
42 | "${workspaceRoot}/build/include",
43 | "${workspaceRoot}/components/tft",
44 | "${workspaceRoot}/components/spiffs",
45 | "${workspaceRoot}/components/spidriver",
46 | "/usr/include/c++/7",
47 | "/usr/include/x86_64-linux-gnu/c++/7",
48 | "/usr/include/c++/7/backward",
49 | "/usr/lib/gcc/x86_64-linux-gnu/7/include",
50 | "/usr/local/include",
51 | "/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed",
52 | "/usr/include/x86_64-linux-gnu",
53 | "/usr/include",
54 | "${workspaceRoot}"
55 | ],
56 | "defines": [],
57 | "intelliSenseMode": "clang-x64",
58 | "browse": {
59 | "path": [
60 | "/home/LoBo2_Razno/ESP32/esp-idf/components",
61 | "/usr/include/c++/7",
62 | "/usr/include/x86_64-linux-gnu/c++/7",
63 | "/usr/include/c++/7/backward",
64 | "/usr/lib/gcc/x86_64-linux-gnu/7/include",
65 | "/usr/local/include",
66 | "/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed",
67 | "/usr/include/x86_64-linux-gnu",
68 | "/usr/include",
69 | "${workspaceRoot}"
70 | ],
71 | "limitSymbolsToIncludedHeaders": true,
72 | "databaseFilename": ""
73 | }
74 | },
75 | {
76 | "name": "Win32",
77 | "includePath": [
78 | "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
79 | "${workspaceRoot}"
80 | ],
81 | "defines": [
82 | "_DEBUG",
83 | "UNICODE"
84 | ],
85 | "intelliSenseMode": "msvc-x64",
86 | "browse": {
87 | "path": [
88 | "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*",
89 | "${workspaceRoot}"
90 | ],
91 | "limitSymbolsToIncludedHeaders": true,
92 | "databaseFilename": ""
93 | }
94 | }
95 | ],
96 | "version": 3
97 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.1.0",
3 | "command": "bash",
4 | "args": ["-c"],
5 | "isShellCommand": true,
6 | "showOutput": "always",
7 | "suppressTaskName": true,
8 | "options": {
9 | "cwd": "${workspaceRoot}"
10 | },
11 | "tasks": [
12 | {
13 | "taskName": "build app",
14 | "args": ["./BUILD all"],
15 | "isBuildCommand": false,
16 | "problemMatcher": {
17 | "owner": "cpp",
18 | "fileLocation": "absolute",
19 | "pattern": {
20 | "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
21 | "file": 1,
22 | "line": 2,
23 | "column": 3,
24 | "severity": 4,
25 | "message": 5
26 | }
27 | }
28 | },
29 | {
30 | "taskName": "build app -j8",
31 | "args": ["./BUILD -j8 all"],
32 | "isBuildCommand": true,
33 | "problemMatcher": {
34 | "owner": "cpp",
35 | "fileLocation": "absolute",
36 | "pattern": {
37 | "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
38 | "file": 1,
39 | "line": 2,
40 | "column": 3,
41 | "severity": 4,
42 | "message": 5
43 | }
44 | }
45 | },
46 | {
47 | "taskName": "clean app",
48 | "args": ["./BUILD clean"]
49 | },
50 | {
51 | "taskName": "flash app",
52 | "args": ["make app-flash"]
53 | },
54 | {
55 | "taskName": "monitor",
56 | "command": "gnome-terminal",
57 | "args": ["-e","make monitor"],
58 | "isShellCommand": false,
59 | "showOutput": "never"
60 | },
61 | {
62 | "taskName": "menuconfig",
63 | "command": "gnome-terminal",
64 | "args": ["-e","make menuconfig"],
65 | "isShellCommand": false,
66 | "showOutput": "never"
67 | }
68 | ]
69 | }
--------------------------------------------------------------------------------
/Documents/ER-TFTM035-6_Datasheet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loboris/ESP32_TFT_library/aa21772f54a71887ec08b2e8bbaef9e304009891/Documents/ER-TFTM035-6_Datasheet.pdf
--------------------------------------------------------------------------------
/Documents/ER-TFTM035-6_Interfacing.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loboris/ESP32_TFT_library/aa21772f54a71887ec08b2e8bbaef9e304009891/Documents/ER-TFTM035-6_Interfacing.pdf
--------------------------------------------------------------------------------
/Documents/FT6236-FT6336-FT6436L-FT6436_Datasheet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loboris/ESP32_TFT_library/aa21772f54a71887ec08b2e8bbaef9e304009891/Documents/FT6236-FT6336-FT6436L-FT6436_Datasheet.pdf
--------------------------------------------------------------------------------
/Documents/ILI9341.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loboris/ESP32_TFT_library/aa21772f54a71887ec08b2e8bbaef9e304009891/Documents/ILI9341.pdf
--------------------------------------------------------------------------------
/Documents/ILI9488.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loboris/ESP32_TFT_library/aa21772f54a71887ec08b2e8bbaef9e304009891/Documents/ILI9488.pdf
--------------------------------------------------------------------------------
/Documents/ST7789S.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loboris/ESP32_TFT_library/aa21772f54a71887ec08b2e8bbaef9e304009891/Documents/ST7789S.pdf
--------------------------------------------------------------------------------
/Documents/ST7789V.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loboris/ESP32_TFT_library/aa21772f54a71887ec08b2e8bbaef9e304009891/Documents/ST7789V.pdf
--------------------------------------------------------------------------------
/Documents/STMPE610-ST Microelectronics.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loboris/ESP32_TFT_library/aa21772f54a71887ec08b2e8bbaef9e304009891/Documents/STMPE610-ST Microelectronics.pdf
--------------------------------------------------------------------------------
/Documents/STMPE610.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loboris/ESP32_TFT_library/aa21772f54a71887ec08b2e8bbaef9e304009891/Documents/STMPE610.pdf
--------------------------------------------------------------------------------
/Documents/XPT2046.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loboris/ESP32_TFT_library/aa21772f54a71887ec08b2e8bbaef9e304009891/Documents/XPT2046.pdf
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a
3 | # project subdirectory.
4 | #
5 |
6 | PROJECT_NAME := tft_demo
7 |
8 | EXTRA_CFLAGS += --save-temps
9 |
10 | include $(IDF_PATH)/make/project.mk
11 |
12 |
--------------------------------------------------------------------------------
/components/mkspiffs/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 | addons:
3 | apt:
4 | sources:
5 | - ubuntu-toolchain-r-test
6 | packages:
7 | - g++-4.8
8 | script:
9 | - export CXX="g++-4.8" CC="gcc-4.8"
10 | - make dist
11 | notifications:
12 | email:
13 | recipients:
14 | - ivan@esp8266.com
15 | on_success: change
16 | on_failure: always
17 | deploy:
18 | provider: releases
19 | api_key:
20 | secure: k/DDoCfLXIct8TcGjekKm5CAoTL6Wy6LXhI74Ssgc8VSbjJQ1crO2J4V5HnQw7QplgAXwqjkoAUkzEJiz34wqBaAv0w9o8+5jPwCP6rMQ/VEvbn1MPI52KIFbYqKxmXe5J24B00BttbGc773ldXPnvmv+qPWWcXDTpcosni2laBt3z8bxCGVwkQ7nuQUaAelzs21wQuhjmKQ6F1dgNN5XhdJ5qgFYYM8cwiigvcqIaCwLMcrOs7gj22TS242pzp38etWhfxUbqUKejWgOH4qYeU3Tf5gsu4WV0otbqXYMvV18gVSoAiMnodDfYJUNHlfelCAEqebvECrIvvE8D0syuVYz6fh2/BrxZ6HeiYj1CXILghOjPUZZZ7/chKglWnA1vL+6Uxn5LtyTJ5gbgMYXvKQUXrRVZ3Zd9xrmv/YaMnGq+6BDBkS30aXpSK2X0HvW9/6JyQ9L1sjnKdOzDmagvikHm2rrPXBRMMfYTt4nucgUBWqJqyFe0uGva/n8TG5RzOzdOgRxFx/lF8XudtR4Z4gUBUFpve/meVHVVK82+cxzfN97aFdxvBzyGq18EDjOEpDi7k7mZjXUycvD8UZ7o12sxJ0Zr6/9esiFUsaqyE+2Vi6bMbgEHGx7hfWbdfREnpOtjFLH+u5mAPIqOh89a/UJ6SbYm0cON+ewTMUkJ8=
21 | file: mkspiffs-$TRAVIS_TAG-linux64.tar.gz
22 | on:
23 | repo: igrr/mkspiffs
24 | tags: true
25 |
--------------------------------------------------------------------------------
/components/mkspiffs/Makefile.projbuild:
--------------------------------------------------------------------------------
1 | MKSPIFFS_COMPONENT_PATH := $(COMPONENT_PATH)
2 | MKSPIFFS_BUILD_DIR=$(abspath $(MKSPIFFS_COMPONENT_PATH)/mkspiffs)
3 |
4 | # Custom recursive make for mkspiffs sub-project
5 | MKSPIFFS_MAKE=+$(MAKE) -C $(MKSPIFFS_COMPONENT_PATH)/src
6 |
7 | .PHONY: mkspiffs clean
8 |
9 | mkspiffs: $(SDKCONFIG_MAKEFILE)
10 | $(MKSPIFFS_MAKE) all
11 |
12 | clean: $(SDKCONFIG_MAKEFILE)
13 | $(MKSPIFFS_MAKE) clean
14 |
15 |
--------------------------------------------------------------------------------
/components/mkspiffs/component.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Component Makefile
3 | #
4 |
5 | COMPONENT_SRCDIRS :=
6 | COMPONENT_ADD_INCLUDEDIRS :=
7 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/Makefile:
--------------------------------------------------------------------------------
1 | CFLAGS ?= -std=gnu99 -Os -Wall
2 | CXXFLAGS ?= -std=gnu++11 -Os -Wall
3 |
4 | ifeq ($(OS),Windows_NT)
5 | TARGET_OS := WINDOWS
6 | DIST_SUFFIX := windows
7 | ARCHIVE_CMD := 7z a
8 | ARCHIVE_EXTENSION := zip
9 | TARGET := mkspiffs.exe
10 | CC=gcc.exe
11 | CXX=g++.exe
12 | TARGET_CFLAGS := -mno-ms-bitfields
13 | TARGET_LDFLAGS := -Wl,-static -static-libgcc
14 |
15 | else
16 | UNAME_S := $(shell uname -s)
17 | ifeq ($(UNAME_S),Linux)
18 | TARGET_OS := LINUX
19 | UNAME_P := $(shell uname -p)
20 | ifeq ($(UNAME_P),x86_64)
21 | DIST_SUFFIX := linux64
22 | endif
23 | ifneq ($(filter %86,$(UNAME_P)),)
24 | DIST_SUFFIX := linux32
25 | endif
26 | CC=gcc
27 | CXX=g++
28 | TARGET_CFLAGS = -std=gnu99 -Os -Wall -Itclap -Ispiffs -I. -D$(TARGET_OS) -DVERSION=\"$(VERSION)\" -D__NO_INLINE__
29 | TARGET_CXXFLAGS = -std=gnu++11 -Os -Wall -Itclap -Ispiffs -I. -D$(TARGET_OS) -DVERSION=\"$(VERSION)\" -D__NO_INLINE__
30 | endif
31 | ifeq ($(UNAME_S),Darwin)
32 | TARGET_OS := OSX
33 | DIST_SUFFIX := osx
34 | CC=clang
35 | CXX=clang++
36 | TARGET_CFLAGS = -std=gnu99 -Os -Wall -Itclap -Ispiffs -I. -D$(TARGET_OS) -DVERSION=\"$(VERSION)\" -D__NO_INLINE__ -mmacosx-version-min=10.7 -arch x86_64
37 | TARGET_CXXFLAGS = -std=gnu++11 -Os -Wall -Itclap -Ispiffs -I. -D$(TARGET_OS) -DVERSION=\"$(VERSION)\" -D__NO_INLINE__ -mmacosx-version-min=10.7 -arch x86_64 -stdlib=libc++
38 | TARGET_LDFLAGS = -arch x86_64 -stdlib=libc++
39 | endif
40 | ARCHIVE_CMD := tar czf
41 | ARCHIVE_EXTENSION := tar.gz
42 | TARGET := mkspiffs
43 | endif
44 |
45 | OBJ := main.o \
46 | spiffs/spiffs_cache.o \
47 | spiffs/spiffs_check.o \
48 | spiffs/spiffs_gc.o \
49 | spiffs/spiffs_hydrogen.o \
50 | spiffs/spiffs_nucleus.o \
51 |
52 | VERSION ?= $(shell git describe --always)
53 |
54 | .PHONY: all clean
55 |
56 | all: $(TARGET)
57 |
58 | $(TARGET):
59 | @echo "Building mkspiffs ..."
60 | $(CC) $(TARGET_CFLAGS) -c spiffs/spiffs_cache.c -o spiffs/spiffs_cache.o
61 | $(CC) $(TARGET_CFLAGS) -c spiffs/spiffs_check.c -o spiffs/spiffs_check.o
62 | $(CC) $(TARGET_CFLAGS) -c spiffs/spiffs_gc.c -o spiffs/spiffs_gc.o
63 | $(CC) $(TARGET_CFLAGS) -c spiffs/spiffs_hydrogen.c -o spiffs/spiffs_hydrogen.o
64 | $(CC) $(TARGET_CFLAGS) -c spiffs/spiffs_nucleus.c -o spiffs/spiffs_nucleus.o
65 | $(CXX) $(TARGET_CXXFLAGS) -c main.cpp -o main.o
66 | $(CXX) $(TARGET_CFLAGS) -o $(TARGET) $(OBJ) $(TARGET_LDFLAGS)
67 |
68 | clean:
69 | @rm -f *.o
70 | @rm -f spiffs/*.o
71 | @rm -f $(TARGET)
--------------------------------------------------------------------------------
/components/mkspiffs/src/README.md:
--------------------------------------------------------------------------------
1 | # mkspiffs
2 | Tool to build and unpack [SPIFFS](https://github.com/pellepl/spiffs) images.
3 |
4 |
5 | ## Usage
6 |
7 | ```
8 |
9 | mkspiffs {-c |-u |-l|-i} [-d <0-5>] [-b ]
10 | [-p ] [-s ] [--] [--version] [-h]
11 |
12 |
13 |
14 | Where:
15 |
16 | -c , --create
17 | (OR required) create spiffs image from a directory
18 | -- OR --
19 | -u , --unpack
20 | (OR required) unpack spiffs image to a directory
21 | -- OR --
22 | -l, --list
23 | (OR required) list files in spiffs image
24 | -- OR --
25 | -i, --visualize
26 | (OR required) visualize spiffs image
27 |
28 |
29 | -d <0-5>, --debug <0-5>
30 | Debug level. 0 means no debug output.
31 |
32 | -b , --block
33 | fs block size, in bytes
34 |
35 | -p , --page
36 | fs page size, in bytes
37 |
38 | -s , --size
39 | fs image size, in bytes
40 |
41 | --, --ignore_rest
42 | Ignores the rest of the labeled arguments following this flag.
43 |
44 | --version
45 | Displays version information and exits.
46 |
47 | -h, --help
48 | Displays usage information and exits.
49 |
50 |
51 | (required) spiffs image file
52 |
53 |
54 | ```
55 | ## Build
56 |
57 | You need gcc (≥4.8) or clang(≥600.0.57), and make. On Windows, use MinGW.
58 |
59 | Run:
60 | ```bash
61 | $ make dist
62 | ```
63 |
64 | ### Build status
65 |
66 | Linux | Windows
67 | ------|-------
68 | [](https://travis-ci.org/igrr/mkspiffs) | [](https://ci.appveyor.com/project/igrr/mkspiffs)
69 |
70 |
71 | ## License
72 |
73 | MIT
74 |
75 | ## To do
76 |
77 | - [ ] Add more debug output and print SPIFFS debug output
78 | - [ ] Error handling
79 | - [ ] Determine the image size automatically when opening a file
80 | - [ ] Code cleanup
81 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 0.0.{build}
2 |
3 | platform:
4 | - x86
5 |
6 | skip_commits:
7 | message: /\[ci skip\]/
8 |
9 | matrix:
10 | fast_finish: true
11 |
12 | build_script:
13 | - SET PATH=C:\MinGW\bin;C:\MinGW\msys\1.0\bin;%PATH%
14 | - make dist
15 |
16 | artifacts:
17 | - path: '*.zip'
18 |
19 | deploy:
20 | release: $(PRODUCT_VERSION)
21 | provider: GitHub
22 | auth_token:
23 | secure: 'PGg5fnoBpP1Omzr6f3KIYDiD8J30rretQjSl/MITRpzvSCmN88kM6VDMz1TBGZTA'
24 | artifact: /.*\.zip/
25 | draft: true
26 | prerelease: false
27 | on:
28 | appveyor_repo_tag: true
29 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/spiffs/esp_spiffs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Lua RTOS, SPIFFS low access
3 | *
4 | * Copyright (C) 2015 - 2017
5 | * IBEROXARXA SERVICIOS INTEGRALES, S.L. & CSS IBÉRICA, S.L.
6 | *
7 | * Author: Jaume Olivé (jolive@iberoxarxa.com / jolive@whitecatboard.org)
8 | *
9 | * All rights reserved.
10 | *
11 | * Permission to use, copy, modify, and distribute this software
12 | * and its documentation for any purpose and without fee is hereby
13 | * granted, provided that the above copyright notice appear in all
14 | * copies and that both that the copyright notice and this
15 | * permission notice and warranty disclaimer appear in supporting
16 | * documentation, and that the name of the author not be used in
17 | * advertising or publicity pertaining to distribution of the
18 | * software without specific, written prior permission.
19 | *
20 | * The author disclaim all warranties with regard to this
21 | * software, including all implied warranties of merchantability
22 | * and fitness. In no event shall the author be liable for any
23 | * special, indirect or consequential damages or any damages
24 | * whatsoever resulting from loss of use, data or profits, whether
25 | * in an action of contract, negligence or other tortious action,
26 | * arising out of or in connection with the use or performance of
27 | * this software.
28 | */
29 |
30 | #include
31 |
32 | #include "esp_spiffs.h"
33 | #include "esp_attr.h"
34 |
35 | #include "spiffs.h"
36 |
37 | #include
38 |
39 | s32_t esp32_spi_flash_read(u32_t addr, u32_t size, u8_t *dst) {
40 | u32_t aaddr;
41 | u8_t *buff = NULL;
42 | u8_t *abuff = NULL;
43 | u32_t asize;
44 |
45 | asize = size;
46 |
47 | // Align address to 4 byte
48 | aaddr = (addr + (4 - 1)) & (u32_t)-4;
49 | if (aaddr != addr) {
50 | aaddr -= 4;
51 | asize += (addr - aaddr);
52 | }
53 |
54 | // Align size to 4 byte
55 | asize = (asize + (4 - 1)) & (u32_t)-4;
56 |
57 | if ((aaddr != addr) || (asize != size)) {
58 | // Align buffer
59 | buff = malloc(asize + 4);
60 | if (!buff) {
61 | return SPIFFS_ERR_INTERNAL;
62 | }
63 |
64 | abuff = (u8_t *)(((ptrdiff_t)buff + (4 - 1)) & (u32_t)-4);
65 |
66 | if (spi_flash_read(aaddr, (void *)abuff, asize) != 0) {
67 | free(buff);
68 | return SPIFFS_ERR_INTERNAL;
69 | }
70 |
71 | memcpy(dst, abuff + (addr - aaddr), size);
72 |
73 | free(buff);
74 | } else {
75 | if (spi_flash_read(addr, (void *)dst, size) != 0) {
76 | return SPIFFS_ERR_INTERNAL;
77 | }
78 | }
79 |
80 | return SPIFFS_OK;
81 | }
82 |
83 | s32_t esp32_spi_flash_write(u32_t addr, u32_t size, const u8_t *src) {
84 | u32_t aaddr;
85 | u8_t *buff = NULL;
86 | u8_t *abuff = NULL;
87 | u32_t asize;
88 |
89 | asize = size;
90 |
91 | // Align address to 4 byte
92 | aaddr = (addr + (4 - 1)) & -4;
93 | if (aaddr != addr) {
94 | aaddr -= 4;
95 | asize += (addr - aaddr);
96 | }
97 |
98 | // Align size to 4 byte
99 | asize = (asize + (4 - 1)) & -4;
100 |
101 | if ((aaddr != addr) || (asize != size)) {
102 | // Align buffer
103 | buff = malloc(asize + 4);
104 | if (!buff) {
105 | return SPIFFS_ERR_INTERNAL;
106 | }
107 |
108 | abuff = (u8_t *)(((ptrdiff_t)buff + (4 - 1)) & -4);
109 |
110 | if (spi_flash_read(aaddr, (void *)abuff, asize) != 0) {
111 | free(buff);
112 | return SPIFFS_ERR_INTERNAL;
113 | }
114 |
115 | memcpy(abuff + (addr - aaddr), src, size);
116 |
117 | if (spi_flash_write(aaddr, (uint32_t *)abuff, asize) != 0) {
118 | free(buff);
119 | return SPIFFS_ERR_INTERNAL;
120 | }
121 |
122 | free(buff);
123 | } else {
124 | if (spi_flash_write(addr, (uint32_t *)src, size) != 0) {
125 | return SPIFFS_ERR_INTERNAL;
126 | }
127 | }
128 |
129 | return SPIFFS_OK;
130 | }
131 |
132 | s32_t IRAM_ATTR esp32_spi_flash_erase(u32_t addr, u32_t size) {
133 | if (spi_flash_erase_sector(addr >> 12) != 0) {
134 | return SPIFFS_ERR_INTERNAL;
135 | }
136 |
137 | return SPIFFS_OK;
138 | }
139 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/spiffs/esp_spiffs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Lua RTOS, write syscall implementation
3 | *
4 | * Copyright (C) 2015 - 2017
5 | * IBEROXARXA SERVICIOS INTEGRALES, S.L. & CSS IBÉRICA, S.L.
6 | *
7 | * Author: Jaume Olivé (jolive@iberoxarxa.com / jolive@whitecatboard.org)
8 | *
9 | * All rights reserved.
10 | *
11 | * Permission to use, copy, modify, and distribute this software
12 | * and its documentation for any purpose and without fee is hereby
13 | * granted, provided that the above copyright notice appear in all
14 | * copies and that both that the copyright notice and this
15 | * permission notice and warranty disclaimer appear in supporting
16 | * documentation, and that the name of the author not be used in
17 | * advertising or publicity pertaining to distribution of the
18 | * software without specific, written prior permission.
19 | *
20 | * The author disclaim all warranties with regard to this
21 | * software, including all implied warranties of merchantability
22 | * and fitness. In no event shall the author be liable for any
23 | * special, indirect or consequential damages or any damages
24 | * whatsoever resulting from loss of use, data or profits, whether
25 | * in an action of contract, negligence or other tortious action,
26 | * arising out of or in connection with the use or performance of
27 | * this software.
28 | */
29 |
30 | #ifndef __ESP_SPIFFS_H__
31 | #define __ESP_SPIFFS_H__
32 |
33 | #include "spiffs.h"
34 |
35 | s32_t esp32_spi_flash_read(u32_t addr, u32_t size, u8_t *dst);
36 | s32_t esp32_spi_flash_write(u32_t addr, u32_t size, const u8_t *src);
37 | s32_t esp32_spi_flash_erase(u32_t addr, u32_t size);
38 |
39 | #define low_spiffs_read (spiffs_read *)esp32_spi_flash_read
40 | #define low_spiffs_write (spiffs_write *)esp32_spi_flash_write
41 | #define low_spiffs_erase (spiffs_erase *)esp32_spi_flash_erase
42 |
43 | #endif // __ESP_SPIFFS_H__
44 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/ArgException.h:
--------------------------------------------------------------------------------
1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2 |
3 | /******************************************************************************
4 | *
5 | * file: ArgException.h
6 | *
7 | * Copyright (c) 2003, Michael E. Smoot .
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 |
24 | #ifndef TCLAP_ARG_EXCEPTION_H
25 | #define TCLAP_ARG_EXCEPTION_H
26 |
27 | #include
28 | #include
29 |
30 | namespace TCLAP {
31 |
32 | /**
33 | * A simple class that defines and argument exception. Should be caught
34 | * whenever a CmdLine is created and parsed.
35 | */
36 | class ArgException : public std::exception
37 | {
38 | public:
39 |
40 | /**
41 | * Constructor.
42 | * \param text - The text of the exception.
43 | * \param id - The text identifying the argument source.
44 | * \param td - Text describing the type of ArgException it is.
45 | * of the exception.
46 | */
47 | ArgException( const std::string& text = "undefined exception",
48 | const std::string& id = "undefined",
49 | const std::string& td = "Generic ArgException")
50 | : std::exception(),
51 | _errorText(text),
52 | _argId( id ),
53 | _typeDescription(td)
54 | { }
55 |
56 | /**
57 | * Destructor.
58 | */
59 | virtual ~ArgException() throw() { }
60 |
61 | /**
62 | * Returns the error text.
63 | */
64 | std::string error() const { return ( _errorText ); }
65 |
66 | /**
67 | * Returns the argument id.
68 | */
69 | std::string argId() const
70 | {
71 | if ( _argId == "undefined" )
72 | return " ";
73 | else
74 | return ( "Argument: " + _argId );
75 | }
76 |
77 | /**
78 | * Returns the arg id and error text.
79 | */
80 | const char* what() const throw()
81 | {
82 | static std::string ex;
83 | ex = _argId + " -- " + _errorText;
84 | return ex.c_str();
85 | }
86 |
87 | /**
88 | * Returns the type of the exception. Used to explain and distinguish
89 | * between different child exceptions.
90 | */
91 | std::string typeDescription() const
92 | {
93 | return _typeDescription;
94 | }
95 |
96 |
97 | private:
98 |
99 | /**
100 | * The text of the exception message.
101 | */
102 | std::string _errorText;
103 |
104 | /**
105 | * The argument related to this exception.
106 | */
107 | std::string _argId;
108 |
109 | /**
110 | * Describes the type of the exception. Used to distinguish
111 | * between different child exceptions.
112 | */
113 | std::string _typeDescription;
114 |
115 | };
116 |
117 | /**
118 | * Thrown from within the child Arg classes when it fails to properly
119 | * parse the argument it has been passed.
120 | */
121 | class ArgParseException : public ArgException
122 | {
123 | public:
124 | /**
125 | * Constructor.
126 | * \param text - The text of the exception.
127 | * \param id - The text identifying the argument source
128 | * of the exception.
129 | */
130 | ArgParseException( const std::string& text = "undefined exception",
131 | const std::string& id = "undefined" )
132 | : ArgException( text,
133 | id,
134 | std::string( "Exception found while parsing " ) +
135 | std::string( "the value the Arg has been passed." ))
136 | { }
137 | };
138 |
139 | /**
140 | * Thrown from CmdLine when the arguments on the command line are not
141 | * properly specified, e.g. too many arguments, required argument missing, etc.
142 | */
143 | class CmdLineParseException : public ArgException
144 | {
145 | public:
146 | /**
147 | * Constructor.
148 | * \param text - The text of the exception.
149 | * \param id - The text identifying the argument source
150 | * of the exception.
151 | */
152 | CmdLineParseException( const std::string& text = "undefined exception",
153 | const std::string& id = "undefined" )
154 | : ArgException( text,
155 | id,
156 | std::string( "Exception found when the values ") +
157 | std::string( "on the command line do not meet ") +
158 | std::string( "the requirements of the defined ") +
159 | std::string( "Args." ))
160 | { }
161 | };
162 |
163 | /**
164 | * Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
165 | * same flag as another Arg, same name, etc.
166 | */
167 | class SpecificationException : public ArgException
168 | {
169 | public:
170 | /**
171 | * Constructor.
172 | * \param text - The text of the exception.
173 | * \param id - The text identifying the argument source
174 | * of the exception.
175 | */
176 | SpecificationException( const std::string& text = "undefined exception",
177 | const std::string& id = "undefined" )
178 | : ArgException( text,
179 | id,
180 | std::string("Exception found when an Arg object ")+
181 | std::string("is improperly defined by the ") +
182 | std::string("developer." ))
183 | { }
184 |
185 | };
186 |
187 | class ExitException {
188 | public:
189 | ExitException(int estat) : _estat(estat) {}
190 |
191 | int getExitStatus() const { return _estat; }
192 |
193 | private:
194 | int _estat;
195 | };
196 |
197 | } // namespace TCLAP
198 |
199 | #endif
200 |
201 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/ArgTraits.h:
--------------------------------------------------------------------------------
1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2 |
3 | /******************************************************************************
4 | *
5 | * file: ArgTraits.h
6 | *
7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot .
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 | // This is an internal tclap file, you should probably not have to
24 | // include this directly
25 |
26 | #ifndef TCLAP_ARGTRAITS_H
27 | #define TCLAP_ARGTRAITS_H
28 |
29 | namespace TCLAP {
30 |
31 | // We use two empty structs to get compile type specialization
32 | // function to work
33 |
34 | /**
35 | * A value like argument value type is a value that can be set using
36 | * operator>>. This is the default value type.
37 | */
38 | struct ValueLike {
39 | typedef ValueLike ValueCategory;
40 | virtual ~ValueLike() {}
41 | };
42 |
43 | /**
44 | * A string like argument value type is a value that can be set using
45 | * operator=(string). Usefull if the value type contains spaces which
46 | * will be broken up into individual tokens by operator>>.
47 | */
48 | struct StringLike {
49 | virtual ~StringLike() {}
50 | };
51 |
52 | /**
53 | * A class can inherit from this object to make it have string like
54 | * traits. This is a compile time thing and does not add any overhead
55 | * to the inherenting class.
56 | */
57 | struct StringLikeTrait {
58 | typedef StringLike ValueCategory;
59 | virtual ~StringLikeTrait() {}
60 | };
61 |
62 | /**
63 | * A class can inherit from this object to make it have value like
64 | * traits. This is a compile time thing and does not add any overhead
65 | * to the inherenting class.
66 | */
67 | struct ValueLikeTrait {
68 | typedef ValueLike ValueCategory;
69 | virtual ~ValueLikeTrait() {}
70 | };
71 |
72 | /**
73 | * Arg traits are used to get compile type specialization when parsing
74 | * argument values. Using an ArgTraits you can specify the way that
75 | * values gets assigned to any particular type during parsing. The two
76 | * supported types are StringLike and ValueLike.
77 | */
78 | template
79 | struct ArgTraits {
80 | typedef typename T::ValueCategory ValueCategory;
81 | virtual ~ArgTraits() {}
82 | //typedef ValueLike ValueCategory;
83 | };
84 |
85 | #endif
86 |
87 | } // namespace
88 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/COPYING:
--------------------------------------------------------------------------------
1 |
2 |
3 | Copyright (c) 2003 Michael E. Smoot
4 |
5 | Permission is hereby granted, free of charge, to any person
6 | obtaining a copy of this software and associated documentation
7 | files (the "Software"), to deal in the Software without restriction,
8 | including without limitation the rights to use, copy, modify, merge,
9 | publish, distribute, sublicense, and/or sell copies of the Software,
10 | and to permit persons to whom the Software is furnished to do so,
11 | subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 |
26 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/CmdLineInterface.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: CmdLineInterface.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot .
7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 | #ifndef TCLAP_COMMANDLINE_INTERFACE_H
24 | #define TCLAP_COMMANDLINE_INTERFACE_H
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 |
33 | namespace TCLAP {
34 |
35 | class Arg;
36 | class CmdLineOutput;
37 | class XorHandler;
38 |
39 | /**
40 | * The base class that manages the command line definition and passes
41 | * along the parsing to the appropriate Arg classes.
42 | */
43 | class CmdLineInterface
44 | {
45 | public:
46 |
47 | /**
48 | * Destructor
49 | */
50 | virtual ~CmdLineInterface() {}
51 |
52 | /**
53 | * Adds an argument to the list of arguments to be parsed.
54 | * \param a - Argument to be added.
55 | */
56 | virtual void add( Arg& a )=0;
57 |
58 | /**
59 | * An alternative add. Functionally identical.
60 | * \param a - Argument to be added.
61 | */
62 | virtual void add( Arg* a )=0;
63 |
64 | /**
65 | * Add two Args that will be xor'd.
66 | * If this method is used, add does
67 | * not need to be called.
68 | * \param a - Argument to be added and xor'd.
69 | * \param b - Argument to be added and xor'd.
70 | */
71 | virtual void xorAdd( Arg& a, Arg& b )=0;
72 |
73 | /**
74 | * Add a list of Args that will be xor'd. If this method is used,
75 | * add does not need to be called.
76 | * \param xors - List of Args to be added and xor'd.
77 | */
78 | virtual void xorAdd( std::vector& xors )=0;
79 |
80 | /**
81 | * Parses the command line.
82 | * \param argc - Number of arguments.
83 | * \param argv - Array of arguments.
84 | */
85 | virtual void parse(int argc, const char * const * argv)=0;
86 |
87 | /**
88 | * Parses the command line.
89 | * \param args - A vector of strings representing the args.
90 | * args[0] is still the program name.
91 | */
92 | void parse(std::vector& args);
93 |
94 | /**
95 | * Returns the CmdLineOutput object.
96 | */
97 | virtual CmdLineOutput* getOutput()=0;
98 |
99 | /**
100 | * \param co - CmdLineOutput object that we want to use instead.
101 | */
102 | virtual void setOutput(CmdLineOutput* co)=0;
103 |
104 | /**
105 | * Returns the version string.
106 | */
107 | virtual std::string& getVersion()=0;
108 |
109 | /**
110 | * Returns the program name string.
111 | */
112 | virtual std::string& getProgramName()=0;
113 |
114 | /**
115 | * Returns the argList.
116 | */
117 | virtual std::list& getArgList()=0;
118 |
119 | /**
120 | * Returns the XorHandler.
121 | */
122 | virtual XorHandler& getXorHandler()=0;
123 |
124 | /**
125 | * Returns the delimiter string.
126 | */
127 | virtual char getDelimiter()=0;
128 |
129 | /**
130 | * Returns the message string.
131 | */
132 | virtual std::string& getMessage()=0;
133 |
134 | /**
135 | * Indicates whether or not the help and version switches were created
136 | * automatically.
137 | */
138 | virtual bool hasHelpAndVersion()=0;
139 |
140 | /**
141 | * Resets the instance as if it had just been constructed so that the
142 | * instance can be reused.
143 | */
144 | virtual void reset()=0;
145 | };
146 |
147 | } //namespace
148 |
149 |
150 | #endif
151 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/CmdLineOutput.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /******************************************************************************
4 | *
5 | * file: CmdLineOutput.h
6 | *
7 | * Copyright (c) 2004, Michael E. Smoot
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 | #ifndef TCLAP_CMDLINEOUTPUT_H
24 | #define TCLAP_CMDLINEOUTPUT_H
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | namespace TCLAP {
34 |
35 | class CmdLineInterface;
36 | class ArgException;
37 |
38 | /**
39 | * The interface that any output object must implement.
40 | */
41 | class CmdLineOutput
42 | {
43 |
44 | public:
45 |
46 | /**
47 | * Virtual destructor.
48 | */
49 | virtual ~CmdLineOutput() {}
50 |
51 | /**
52 | * Generates some sort of output for the USAGE.
53 | * \param c - The CmdLine object the output is generated for.
54 | */
55 | virtual void usage(CmdLineInterface& c)=0;
56 |
57 | /**
58 | * Generates some sort of output for the version.
59 | * \param c - The CmdLine object the output is generated for.
60 | */
61 | virtual void version(CmdLineInterface& c)=0;
62 |
63 | /**
64 | * Generates some sort of output for a failure.
65 | * \param c - The CmdLine object the output is generated for.
66 | * \param e - The ArgException that caused the failure.
67 | */
68 | virtual void failure( CmdLineInterface& c,
69 | ArgException& e )=0;
70 |
71 | };
72 |
73 | } //namespace TCLAP
74 | #endif
75 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/Constraint.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: Constraint.h
5 | *
6 | * Copyright (c) 2005, Michael E. Smoot
7 | * All rights reverved.
8 | *
9 | * See the file COPYING in the top directory of this distribution for
10 | * more information.
11 | *
12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 | * DEALINGS IN THE SOFTWARE.
19 | *
20 | *****************************************************************************/
21 |
22 | #ifndef TCLAP_CONSTRAINT_H
23 | #define TCLAP_CONSTRAINT_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | namespace TCLAP {
33 |
34 | /**
35 | * The interface that defines the interaction between the Arg and Constraint.
36 | */
37 | template
38 | class Constraint
39 | {
40 |
41 | public:
42 | /**
43 | * Returns a description of the Constraint.
44 | */
45 | virtual std::string description() const =0;
46 |
47 | /**
48 | * Returns the short ID for the Constraint.
49 | */
50 | virtual std::string shortID() const =0;
51 |
52 | /**
53 | * The method used to verify that the value parsed from the command
54 | * line meets the constraint.
55 | * \param value - The value that will be checked.
56 | */
57 | virtual bool check(const T& value) const =0;
58 |
59 | /**
60 | * Destructor.
61 | * Silences warnings about Constraint being a base class with virtual
62 | * functions but without a virtual destructor.
63 | */
64 | virtual ~Constraint() { ; }
65 | };
66 |
67 | } //namespace TCLAP
68 | #endif
69 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/DocBookOutput.h:
--------------------------------------------------------------------------------
1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2 |
3 | /******************************************************************************
4 | *
5 | * file: DocBookOutput.h
6 | *
7 | * Copyright (c) 2004, Michael E. Smoot
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 | #ifndef TCLAP_DOCBOOKOUTPUT_H
24 | #define TCLAP_DOCBOOKOUTPUT_H
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | #include "CmdLineInterface.h"
33 | #include "CmdLineOutput.h"
34 | #include "XorHandler.h"
35 | #include "Arg.h"
36 |
37 | namespace TCLAP {
38 |
39 | /**
40 | * A class that generates DocBook output for usage() method for the
41 | * given CmdLine and its Args.
42 | */
43 | class DocBookOutput : public CmdLineOutput
44 | {
45 |
46 | public:
47 |
48 | /**
49 | * Prints the usage to stdout. Can be overridden to
50 | * produce alternative behavior.
51 | * \param c - The CmdLine object the output is generated for.
52 | */
53 | virtual void usage(CmdLineInterface& c);
54 |
55 | /**
56 | * Prints the version to stdout. Can be overridden
57 | * to produce alternative behavior.
58 | * \param c - The CmdLine object the output is generated for.
59 | */
60 | virtual void version(CmdLineInterface& c);
61 |
62 | /**
63 | * Prints (to stderr) an error message, short usage
64 | * Can be overridden to produce alternative behavior.
65 | * \param c - The CmdLine object the output is generated for.
66 | * \param e - The ArgException that caused the failure.
67 | */
68 | virtual void failure(CmdLineInterface& c,
69 | ArgException& e );
70 |
71 | protected:
72 |
73 | /**
74 | * Substitutes the char r for string x in string s.
75 | * \param s - The string to operate on.
76 | * \param r - The char to replace.
77 | * \param x - What to replace r with.
78 | */
79 | void substituteSpecialChars( std::string& s, char r, std::string& x );
80 | void removeChar( std::string& s, char r);
81 | void basename( std::string& s );
82 |
83 | void printShortArg(Arg* it);
84 | void printLongArg(Arg* it);
85 |
86 | char theDelimiter;
87 | };
88 |
89 |
90 | inline void DocBookOutput::version(CmdLineInterface& _cmd)
91 | {
92 | std::cout << _cmd.getVersion() << std::endl;
93 | }
94 |
95 | inline void DocBookOutput::usage(CmdLineInterface& _cmd )
96 | {
97 | std::list argList = _cmd.getArgList();
98 | std::string progName = _cmd.getProgramName();
99 | std::string xversion = _cmd.getVersion();
100 | theDelimiter = _cmd.getDelimiter();
101 | XorHandler xorHandler = _cmd.getXorHandler();
102 | std::vector< std::vector > xorList = xorHandler.getXorList();
103 | basename(progName);
104 |
105 | std::cout << "" << std::endl;
106 | std::cout << "" << std::endl << std::endl;
108 |
109 | std::cout << "" << std::endl;
110 |
111 | std::cout << "" << std::endl;
112 | std::cout << "" << progName << "" << std::endl;
113 | std::cout << "1" << std::endl;
114 | std::cout << "" << std::endl;
115 |
116 | std::cout << "" << std::endl;
117 | std::cout << "" << progName << "" << std::endl;
118 | std::cout << "" << _cmd.getMessage() << "" << std::endl;
119 | std::cout << "" << std::endl;
120 |
121 | std::cout << "" << std::endl;
122 | std::cout << "" << std::endl;
123 |
124 | std::cout << "" << progName << "" << std::endl;
125 |
126 | // xor
127 | for ( int i = 0; (unsigned int)i < xorList.size(); i++ )
128 | {
129 | std::cout << "" << std::endl;
130 | for ( ArgVectorIterator it = xorList[i].begin();
131 | it != xorList[i].end(); it++ )
132 | printShortArg((*it));
133 |
134 | std::cout << "" << std::endl;
135 | }
136 |
137 | // rest of args
138 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++)
139 | if ( !xorHandler.contains( (*it) ) )
140 | printShortArg((*it));
141 |
142 | std::cout << "" << std::endl;
143 | std::cout << "" << std::endl;
144 |
145 | std::cout << "" << std::endl;
146 | std::cout << "Description" << std::endl;
147 | std::cout << "" << std::endl;
148 | std::cout << _cmd.getMessage() << std::endl;
149 | std::cout << "" << std::endl;
150 | std::cout << "" << std::endl;
151 |
152 | std::cout << "" << std::endl;
153 | std::cout << "Options" << std::endl;
154 |
155 | std::cout << "" << std::endl;
156 |
157 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++)
158 | printLongArg((*it));
159 |
160 | std::cout << "" << std::endl;
161 | std::cout << "" << std::endl;
162 |
163 | std::cout << "" << std::endl;
164 | std::cout << "Version" << std::endl;
165 | std::cout << "" << std::endl;
166 | std::cout << xversion << std::endl;
167 | std::cout << "" << std::endl;
168 | std::cout << "" << std::endl;
169 |
170 | std::cout << "" << std::endl;
171 |
172 | }
173 |
174 | inline void DocBookOutput::failure( CmdLineInterface& _cmd,
175 | ArgException& e )
176 | {
177 | static_cast(_cmd); // unused
178 | std::cout << e.what() << std::endl;
179 | throw ExitException(1);
180 | }
181 |
182 | inline void DocBookOutput::substituteSpecialChars( std::string& s,
183 | char r,
184 | std::string& x )
185 | {
186 | size_t p;
187 | while ( (p = s.find_first_of(r)) != std::string::npos )
188 | {
189 | s.erase(p,1);
190 | s.insert(p,x);
191 | }
192 | }
193 |
194 | inline void DocBookOutput::removeChar( std::string& s, char r)
195 | {
196 | size_t p;
197 | while ( (p = s.find_first_of(r)) != std::string::npos )
198 | {
199 | s.erase(p,1);
200 | }
201 | }
202 |
203 | inline void DocBookOutput::basename( std::string& s )
204 | {
205 | size_t p = s.find_last_of('/');
206 | if ( p != std::string::npos )
207 | {
208 | s.erase(0, p + 1);
209 | }
210 | }
211 |
212 | inline void DocBookOutput::printShortArg(Arg* a)
213 | {
214 | std::string lt = "<";
215 | std::string gt = ">";
216 |
217 | std::string id = a->shortID();
218 | substituteSpecialChars(id,'<',lt);
219 | substituteSpecialChars(id,'>',gt);
220 | removeChar(id,'[');
221 | removeChar(id,']');
222 |
223 | std::string choice = "opt";
224 | if ( a->isRequired() )
225 | choice = "plain";
226 |
227 | std::cout << "acceptsMultipleValues() )
229 | std::cout << " rep='repeat'";
230 |
231 |
232 | std::cout << '>';
233 | if ( !a->getFlag().empty() )
234 | std::cout << a->flagStartChar() << a->getFlag();
235 | else
236 | std::cout << a->nameStartString() << a->getName();
237 | if ( a->isValueRequired() )
238 | {
239 | std::string arg = a->shortID();
240 | removeChar(arg,'[');
241 | removeChar(arg,']');
242 | removeChar(arg,'<');
243 | removeChar(arg,'>');
244 | arg.erase(0, arg.find_last_of(theDelimiter) + 1);
245 | std::cout << theDelimiter;
246 | std::cout << "" << arg << "";
247 | }
248 | std::cout << "" << std::endl;
249 |
250 | }
251 |
252 | inline void DocBookOutput::printLongArg(Arg* a)
253 | {
254 | std::string lt = "<";
255 | std::string gt = ">";
256 |
257 | std::string desc = a->getDescription();
258 | substituteSpecialChars(desc,'<',lt);
259 | substituteSpecialChars(desc,'>',gt);
260 |
261 | std::cout << "" << std::endl;
262 |
263 | if ( !a->getFlag().empty() )
264 | {
265 | std::cout << "" << std::endl;
266 | std::cout << "" << std::endl;
269 | std::cout << "" << std::endl;
270 | }
271 |
272 | std::cout << "" << std::endl;
273 | std::cout << "" << std::endl;
287 | std::cout << "" << std::endl;
288 |
289 | std::cout << "" << std::endl;
290 | std::cout << "" << std::endl;
291 | std::cout << desc << std::endl;
292 | std::cout << "" << std::endl;
293 | std::cout << "" << std::endl;
294 |
295 | std::cout << "" << std::endl;
296 | }
297 |
298 | } //namespace TCLAP
299 | #endif
300 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/HelpVisitor.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: HelpVisitor.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot .
7 | * All rights reverved.
8 | *
9 | * See the file COPYING in the top directory of this distribution for
10 | * more information.
11 | *
12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 | * DEALINGS IN THE SOFTWARE.
19 | *
20 | *****************************************************************************/
21 |
22 | #ifndef TCLAP_HELP_VISITOR_H
23 | #define TCLAP_HELP_VISITOR_H
24 |
25 | #include "CmdLineInterface.h"
26 | #include "CmdLineOutput.h"
27 | #include "Visitor.h"
28 |
29 | namespace TCLAP {
30 |
31 | /**
32 | * A Visitor object that calls the usage method of the given CmdLineOutput
33 | * object for the specified CmdLine object.
34 | */
35 | class HelpVisitor: public Visitor
36 | {
37 | private:
38 | /**
39 | * Prevent accidental copying.
40 | */
41 | HelpVisitor(const HelpVisitor& rhs);
42 | HelpVisitor& operator=(const HelpVisitor& rhs);
43 |
44 | protected:
45 |
46 | /**
47 | * The CmdLine the output will be generated for.
48 | */
49 | CmdLineInterface* _cmd;
50 |
51 | /**
52 | * The output object.
53 | */
54 | CmdLineOutput** _out;
55 |
56 | public:
57 |
58 | /**
59 | * Constructor.
60 | * \param cmd - The CmdLine the output will be generated for.
61 | * \param out - The type of output.
62 | */
63 | HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out)
64 | : Visitor(), _cmd( cmd ), _out( out ) { }
65 |
66 | /**
67 | * Calls the usage method of the CmdLineOutput for the
68 | * specified CmdLine.
69 | */
70 | void visit() { (*_out)->usage(*_cmd); throw ExitException(0); }
71 |
72 | };
73 |
74 | }
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/IgnoreRestVisitor.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: IgnoreRestVisitor.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot .
7 | * All rights reverved.
8 | *
9 | * See the file COPYING in the top directory of this distribution for
10 | * more information.
11 | *
12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 | * DEALINGS IN THE SOFTWARE.
19 | *
20 | *****************************************************************************/
21 |
22 |
23 | #ifndef TCLAP_IGNORE_REST_VISITOR_H
24 | #define TCLAP_IGNORE_REST_VISITOR_H
25 |
26 | #include "Visitor.h"
27 | #include "Arg.h"
28 |
29 | namespace TCLAP {
30 |
31 | /**
32 | * A Vistor that tells the CmdLine to begin ignoring arguments after
33 | * this one is parsed.
34 | */
35 | class IgnoreRestVisitor: public Visitor
36 | {
37 | public:
38 |
39 | /**
40 | * Constructor.
41 | */
42 | IgnoreRestVisitor() : Visitor() {}
43 |
44 | /**
45 | * Sets Arg::_ignoreRest.
46 | */
47 | void visit() { Arg::beginIgnoring(); }
48 | };
49 |
50 | }
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/MultiSwitchArg.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: MultiSwitchArg.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot .
7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
8 | * Copyright (c) 2005, Michael E. Smoot, Daniel Aarno, Erik Zeek.
9 | * All rights reverved.
10 | *
11 | * See the file COPYING in the top directory of this distribution for
12 | * more information.
13 | *
14 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | * DEALINGS IN THE SOFTWARE.
21 | *
22 | *****************************************************************************/
23 |
24 |
25 | #ifndef TCLAP_MULTI_SWITCH_ARG_H
26 | #define TCLAP_MULTI_SWITCH_ARG_H
27 |
28 | #include
29 | #include
30 |
31 | #include "SwitchArg.h"
32 |
33 | namespace TCLAP {
34 |
35 | /**
36 | * A multiple switch argument. If the switch is set on the command line, then
37 | * the getValue method will return the number of times the switch appears.
38 | */
39 | class MultiSwitchArg : public SwitchArg
40 | {
41 | protected:
42 |
43 | /**
44 | * The value of the switch.
45 | */
46 | int _value;
47 |
48 | /**
49 | * Used to support the reset() method so that ValueArg can be
50 | * reset to their constructed value.
51 | */
52 | int _default;
53 |
54 | public:
55 |
56 | /**
57 | * MultiSwitchArg constructor.
58 | * \param flag - The one character flag that identifies this
59 | * argument on the command line.
60 | * \param name - A one word name for the argument. Can be
61 | * used as a long flag on the command line.
62 | * \param desc - A description of what the argument is for or
63 | * does.
64 | * \param init - Optional. The initial/default value of this Arg.
65 | * Defaults to 0.
66 | * \param v - An optional visitor. You probably should not
67 | * use this unless you have a very good reason.
68 | */
69 | MultiSwitchArg(const std::string& flag,
70 | const std::string& name,
71 | const std::string& desc,
72 | int init = 0,
73 | Visitor* v = NULL);
74 |
75 |
76 | /**
77 | * MultiSwitchArg constructor.
78 | * \param flag - The one character flag that identifies this
79 | * argument on the command line.
80 | * \param name - A one word name for the argument. Can be
81 | * used as a long flag on the command line.
82 | * \param desc - A description of what the argument is for or
83 | * does.
84 | * \param parser - A CmdLine parser object to add this Arg to
85 | * \param init - Optional. The initial/default value of this Arg.
86 | * Defaults to 0.
87 | * \param v - An optional visitor. You probably should not
88 | * use this unless you have a very good reason.
89 | */
90 | MultiSwitchArg(const std::string& flag,
91 | const std::string& name,
92 | const std::string& desc,
93 | CmdLineInterface& parser,
94 | int init = 0,
95 | Visitor* v = NULL);
96 |
97 |
98 | /**
99 | * Handles the processing of the argument.
100 | * This re-implements the SwitchArg version of this method to set the
101 | * _value of the argument appropriately.
102 | * \param i - Pointer the the current argument in the list.
103 | * \param args - Mutable list of strings. Passed
104 | * in from main().
105 | */
106 | virtual bool processArg(int* i, std::vector& args);
107 |
108 | /**
109 | * Returns int, the number of times the switch has been set.
110 | */
111 | int getValue();
112 |
113 | /**
114 | * Returns the shortID for this Arg.
115 | */
116 | std::string shortID(const std::string& val) const;
117 |
118 | /**
119 | * Returns the longID for this Arg.
120 | */
121 | std::string longID(const std::string& val) const;
122 |
123 | void reset();
124 |
125 | };
126 |
127 | //////////////////////////////////////////////////////////////////////
128 | //BEGIN MultiSwitchArg.cpp
129 | //////////////////////////////////////////////////////////////////////
130 | inline MultiSwitchArg::MultiSwitchArg(const std::string& flag,
131 | const std::string& name,
132 | const std::string& desc,
133 | int init,
134 | Visitor* v )
135 | : SwitchArg(flag, name, desc, false, v),
136 | _value( init ),
137 | _default( init )
138 | { }
139 |
140 | inline MultiSwitchArg::MultiSwitchArg(const std::string& flag,
141 | const std::string& name,
142 | const std::string& desc,
143 | CmdLineInterface& parser,
144 | int init,
145 | Visitor* v )
146 | : SwitchArg(flag, name, desc, false, v),
147 | _value( init ),
148 | _default( init )
149 | {
150 | parser.add( this );
151 | }
152 |
153 | inline int MultiSwitchArg::getValue() { return _value; }
154 |
155 | inline bool MultiSwitchArg::processArg(int *i, std::vector& args)
156 | {
157 | if ( _ignoreable && Arg::ignoreRest() )
158 | return false;
159 |
160 | if ( argMatches( args[*i] ))
161 | {
162 | // so the isSet() method will work
163 | _alreadySet = true;
164 |
165 | // Matched argument: increment value.
166 | ++_value;
167 |
168 | _checkWithVisitor();
169 |
170 | return true;
171 | }
172 | else if ( combinedSwitchesMatch( args[*i] ) )
173 | {
174 | // so the isSet() method will work
175 | _alreadySet = true;
176 |
177 | // Matched argument: increment value.
178 | ++_value;
179 |
180 | // Check for more in argument and increment value.
181 | while ( combinedSwitchesMatch( args[*i] ) )
182 | ++_value;
183 |
184 | _checkWithVisitor();
185 |
186 | return false;
187 | }
188 | else
189 | return false;
190 | }
191 |
192 | inline std::string
193 | MultiSwitchArg::shortID(const std::string& val) const
194 | {
195 | return Arg::shortID(val) + " ... ";
196 | }
197 |
198 | inline std::string
199 | MultiSwitchArg::longID(const std::string& val) const
200 | {
201 | return Arg::longID(val) + " (accepted multiple times)";
202 | }
203 |
204 | inline void
205 | MultiSwitchArg::reset()
206 | {
207 | MultiSwitchArg::_value = MultiSwitchArg::_default;
208 | }
209 |
210 | //////////////////////////////////////////////////////////////////////
211 | //END MultiSwitchArg.cpp
212 | //////////////////////////////////////////////////////////////////////
213 |
214 | } //namespace TCLAP
215 |
216 | #endif
217 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/OptionalUnlabeledTracker.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /******************************************************************************
4 | *
5 | * file: OptionalUnlabeledTracker.h
6 | *
7 | * Copyright (c) 2005, Michael E. Smoot .
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 |
24 | #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H
25 | #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H
26 |
27 | #include
28 |
29 | namespace TCLAP {
30 |
31 | class OptionalUnlabeledTracker
32 | {
33 |
34 | public:
35 |
36 | static void check( bool req, const std::string& argName );
37 |
38 | static void gotOptional() { alreadyOptionalRef() = true; }
39 |
40 | static bool& alreadyOptional() { return alreadyOptionalRef(); }
41 |
42 | private:
43 |
44 | static bool& alreadyOptionalRef() { static bool ct = false; return ct; }
45 | };
46 |
47 |
48 | inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName )
49 | {
50 | if ( OptionalUnlabeledTracker::alreadyOptional() )
51 | throw( SpecificationException(
52 | "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg",
53 | argName ) );
54 |
55 | if ( !req )
56 | OptionalUnlabeledTracker::gotOptional();
57 | }
58 |
59 |
60 | } // namespace TCLAP
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/StandardTraits.h:
--------------------------------------------------------------------------------
1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2 |
3 | /******************************************************************************
4 | *
5 | * file: StandardTraits.h
6 | *
7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot .
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 | // This is an internal tclap file, you should probably not have to
24 | // include this directly
25 |
26 | #ifndef TCLAP_STANDARD_TRAITS_H
27 | #define TCLAP_STANDARD_TRAITS_H
28 |
29 | #ifdef HAVE_CONFIG_H
30 | #include // To check for long long
31 | #endif
32 |
33 | // If Microsoft has already typedef'd wchar_t as an unsigned
34 | // short, then compiles will break because it's as if we're
35 | // creating ArgTraits twice for unsigned short. Thus...
36 | #ifdef _MSC_VER
37 | #ifndef _NATIVE_WCHAR_T_DEFINED
38 | #define TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS
39 | #endif
40 | #endif
41 |
42 | namespace TCLAP {
43 |
44 | // ======================================================================
45 | // Integer types
46 | // ======================================================================
47 |
48 | /**
49 | * longs have value-like semantics.
50 | */
51 | template<>
52 | struct ArgTraits {
53 | typedef ValueLike ValueCategory;
54 | };
55 |
56 | /**
57 | * ints have value-like semantics.
58 | */
59 | template<>
60 | struct ArgTraits {
61 | typedef ValueLike ValueCategory;
62 | };
63 |
64 | /**
65 | * shorts have value-like semantics.
66 | */
67 | template<>
68 | struct ArgTraits {
69 | typedef ValueLike ValueCategory;
70 | };
71 |
72 | /**
73 | * chars have value-like semantics.
74 | */
75 | template<>
76 | struct ArgTraits {
77 | typedef ValueLike ValueCategory;
78 | };
79 |
80 | #ifdef HAVE_LONG_LONG
81 | /**
82 | * long longs have value-like semantics.
83 | */
84 | template<>
85 | struct ArgTraits {
86 | typedef ValueLike ValueCategory;
87 | };
88 | #endif
89 |
90 | // ======================================================================
91 | // Unsigned integer types
92 | // ======================================================================
93 |
94 | /**
95 | * unsigned longs have value-like semantics.
96 | */
97 | template<>
98 | struct ArgTraits {
99 | typedef ValueLike ValueCategory;
100 | };
101 |
102 | /**
103 | * unsigned ints have value-like semantics.
104 | */
105 | template<>
106 | struct ArgTraits {
107 | typedef ValueLike ValueCategory;
108 | };
109 |
110 | /**
111 | * unsigned shorts have value-like semantics.
112 | */
113 | template<>
114 | struct ArgTraits {
115 | typedef ValueLike ValueCategory;
116 | };
117 |
118 | /**
119 | * unsigned chars have value-like semantics.
120 | */
121 | template<>
122 | struct ArgTraits {
123 | typedef ValueLike ValueCategory;
124 | };
125 |
126 | // Microsoft implements size_t awkwardly.
127 | #if defined(_MSC_VER) && defined(_M_X64)
128 | /**
129 | * size_ts have value-like semantics.
130 | */
131 | template<>
132 | struct ArgTraits {
133 | typedef ValueLike ValueCategory;
134 | };
135 | #endif
136 |
137 |
138 | #ifdef HAVE_LONG_LONG
139 | /**
140 | * unsigned long longs have value-like semantics.
141 | */
142 | template<>
143 | struct ArgTraits {
144 | typedef ValueLike ValueCategory;
145 | };
146 | #endif
147 |
148 | // ======================================================================
149 | // Float types
150 | // ======================================================================
151 |
152 | /**
153 | * floats have value-like semantics.
154 | */
155 | template<>
156 | struct ArgTraits {
157 | typedef ValueLike ValueCategory;
158 | };
159 |
160 | /**
161 | * doubles have value-like semantics.
162 | */
163 | template<>
164 | struct ArgTraits {
165 | typedef ValueLike ValueCategory;
166 | };
167 |
168 | // ======================================================================
169 | // Other types
170 | // ======================================================================
171 |
172 | /**
173 | * bools have value-like semantics.
174 | */
175 | template<>
176 | struct ArgTraits {
177 | typedef ValueLike ValueCategory;
178 | };
179 |
180 |
181 | /**
182 | * wchar_ts have value-like semantics.
183 | */
184 | #ifndef TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS
185 | template<>
186 | struct ArgTraits {
187 | typedef ValueLike ValueCategory;
188 | };
189 | #endif
190 |
191 | /**
192 | * Strings have string like argument traits.
193 | */
194 | template<>
195 | struct ArgTraits {
196 | typedef StringLike ValueCategory;
197 | };
198 |
199 | template
200 | void SetString(T &dst, const std::string &src)
201 | {
202 | dst = src;
203 | }
204 |
205 | } // namespace
206 |
207 | #endif
208 |
209 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/StdOutput.h:
--------------------------------------------------------------------------------
1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2 |
3 | /******************************************************************************
4 | *
5 | * file: StdOutput.h
6 | *
7 | * Copyright (c) 2004, Michael E. Smoot
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 | #ifndef TCLAP_STDCMDLINEOUTPUT_H
24 | #define TCLAP_STDCMDLINEOUTPUT_H
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | #include "CmdLineInterface.h"
33 | #include "CmdLineOutput.h"
34 | #include "XorHandler.h"
35 | #include "Arg.h"
36 |
37 | namespace TCLAP {
38 |
39 | /**
40 | * A class that isolates any output from the CmdLine object so that it
41 | * may be easily modified.
42 | */
43 | class StdOutput : public CmdLineOutput
44 | {
45 |
46 | public:
47 |
48 | /**
49 | * Prints the usage to stdout. Can be overridden to
50 | * produce alternative behavior.
51 | * \param c - The CmdLine object the output is generated for.
52 | */
53 | virtual void usage(CmdLineInterface& c);
54 |
55 | /**
56 | * Prints the version to stdout. Can be overridden
57 | * to produce alternative behavior.
58 | * \param c - The CmdLine object the output is generated for.
59 | */
60 | virtual void version(CmdLineInterface& c);
61 |
62 | /**
63 | * Prints (to stderr) an error message, short usage
64 | * Can be overridden to produce alternative behavior.
65 | * \param c - The CmdLine object the output is generated for.
66 | * \param e - The ArgException that caused the failure.
67 | */
68 | virtual void failure(CmdLineInterface& c,
69 | ArgException& e );
70 |
71 | protected:
72 |
73 | /**
74 | * Writes a brief usage message with short args.
75 | * \param c - The CmdLine object the output is generated for.
76 | * \param os - The stream to write the message to.
77 | */
78 | void _shortUsage( CmdLineInterface& c, std::ostream& os ) const;
79 |
80 | /**
81 | * Writes a longer usage message with long and short args,
82 | * provides descriptions and prints message.
83 | * \param c - The CmdLine object the output is generated for.
84 | * \param os - The stream to write the message to.
85 | */
86 | void _longUsage( CmdLineInterface& c, std::ostream& os ) const;
87 |
88 | /**
89 | * This function inserts line breaks and indents long strings
90 | * according the params input. It will only break lines at spaces,
91 | * commas and pipes.
92 | * \param os - The stream to be printed to.
93 | * \param s - The string to be printed.
94 | * \param maxWidth - The maxWidth allowed for the output line.
95 | * \param indentSpaces - The number of spaces to indent the first line.
96 | * \param secondLineOffset - The number of spaces to indent the second
97 | * and all subsequent lines in addition to indentSpaces.
98 | */
99 | void spacePrint( std::ostream& os,
100 | const std::string& s,
101 | int maxWidth,
102 | int indentSpaces,
103 | int secondLineOffset ) const;
104 |
105 | };
106 |
107 |
108 | inline void StdOutput::version(CmdLineInterface& _cmd)
109 | {
110 | std::string progName = _cmd.getProgramName();
111 | std::string xversion = _cmd.getVersion();
112 |
113 | std::cout << std::endl << progName << " version: "
114 | << xversion << std::endl << std::endl;
115 | }
116 |
117 | inline void StdOutput::usage(CmdLineInterface& _cmd )
118 | {
119 | std::cout << std::endl << "USAGE: " << std::endl << std::endl;
120 |
121 | _shortUsage( _cmd, std::cout );
122 |
123 | std::cout << std::endl << std::endl << "Where: " << std::endl << std::endl;
124 |
125 | _longUsage( _cmd, std::cout );
126 |
127 | std::cout << std::endl;
128 |
129 | }
130 |
131 | inline void StdOutput::failure( CmdLineInterface& _cmd,
132 | ArgException& e )
133 | {
134 | std::string progName = _cmd.getProgramName();
135 |
136 | std::cerr << "PARSE ERROR: " << e.argId() << std::endl
137 | << " " << e.error() << std::endl << std::endl;
138 |
139 | if ( _cmd.hasHelpAndVersion() )
140 | {
141 | std::cerr << "Brief USAGE: " << std::endl;
142 |
143 | _shortUsage( _cmd, std::cerr );
144 |
145 | std::cerr << std::endl << "For complete USAGE and HELP type: "
146 | << std::endl << " " << progName << " --help"
147 | << std::endl << std::endl;
148 | }
149 | else
150 | usage(_cmd);
151 |
152 | throw ExitException(1);
153 | }
154 |
155 | inline void
156 | StdOutput::_shortUsage( CmdLineInterface& _cmd,
157 | std::ostream& os ) const
158 | {
159 | std::list argList = _cmd.getArgList();
160 | std::string progName = _cmd.getProgramName();
161 | XorHandler xorHandler = _cmd.getXorHandler();
162 | std::vector< std::vector > xorList = xorHandler.getXorList();
163 |
164 | std::string s = progName + " ";
165 |
166 | // first the xor
167 | for ( int i = 0; static_cast(i) < xorList.size(); i++ )
168 | {
169 | s += " {";
170 | for ( ArgVectorIterator it = xorList[i].begin();
171 | it != xorList[i].end(); it++ )
172 | s += (*it)->shortID() + "|";
173 |
174 | s[s.length()-1] = '}';
175 | }
176 |
177 | // then the rest
178 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++)
179 | if ( !xorHandler.contains( (*it) ) )
180 | s += " " + (*it)->shortID();
181 |
182 | // if the program name is too long, then adjust the second line offset
183 | int secondLineOffset = static_cast(progName.length()) + 2;
184 | if ( secondLineOffset > 75/2 )
185 | secondLineOffset = static_cast(75/2);
186 |
187 | spacePrint( os, s, 75, 3, secondLineOffset );
188 | }
189 |
190 | inline void
191 | StdOutput::_longUsage( CmdLineInterface& _cmd,
192 | std::ostream& os ) const
193 | {
194 | std::list argList = _cmd.getArgList();
195 | std::string message = _cmd.getMessage();
196 | XorHandler xorHandler = _cmd.getXorHandler();
197 | std::vector< std::vector > xorList = xorHandler.getXorList();
198 |
199 | // first the xor
200 | for ( int i = 0; static_cast(i) < xorList.size(); i++ )
201 | {
202 | for ( ArgVectorIterator it = xorList[i].begin();
203 | it != xorList[i].end();
204 | it++ )
205 | {
206 | spacePrint( os, (*it)->longID(), 75, 3, 3 );
207 | spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
208 |
209 | if ( it+1 != xorList[i].end() )
210 | spacePrint(os, "-- OR --", 75, 9, 0);
211 | }
212 | os << std::endl << std::endl;
213 | }
214 |
215 | // then the rest
216 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++)
217 | if ( !xorHandler.contains( (*it) ) )
218 | {
219 | spacePrint( os, (*it)->longID(), 75, 3, 3 );
220 | spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
221 | os << std::endl;
222 | }
223 |
224 | os << std::endl;
225 |
226 | spacePrint( os, message, 75, 3, 0 );
227 | }
228 |
229 | inline void StdOutput::spacePrint( std::ostream& os,
230 | const std::string& s,
231 | int maxWidth,
232 | int indentSpaces,
233 | int secondLineOffset ) const
234 | {
235 | int len = static_cast(s.length());
236 |
237 | if ( (len + indentSpaces > maxWidth) && maxWidth > 0 )
238 | {
239 | int allowedLen = maxWidth - indentSpaces;
240 | int start = 0;
241 | while ( start < len )
242 | {
243 | // find the substring length
244 | // int stringLen = std::min( len - start, allowedLen );
245 | // doing it this way to support a VisualC++ 2005 bug
246 | using namespace std;
247 | int stringLen = min( len - start, allowedLen );
248 |
249 | // trim the length so it doesn't end in middle of a word
250 | if ( stringLen == allowedLen )
251 | while ( stringLen >= 0 &&
252 | s[stringLen+start] != ' ' &&
253 | s[stringLen+start] != ',' &&
254 | s[stringLen+start] != '|' )
255 | stringLen--;
256 |
257 | // ok, the word is longer than the line, so just split
258 | // wherever the line ends
259 | if ( stringLen <= 0 )
260 | stringLen = allowedLen;
261 |
262 | // check for newlines
263 | for ( int i = 0; i < stringLen; i++ )
264 | if ( s[start+i] == '\n' )
265 | stringLen = i+1;
266 |
267 | // print the indent
268 | for ( int i = 0; i < indentSpaces; i++ )
269 | os << " ";
270 |
271 | if ( start == 0 )
272 | {
273 | // handle second line offsets
274 | indentSpaces += secondLineOffset;
275 |
276 | // adjust allowed len
277 | allowedLen -= secondLineOffset;
278 | }
279 |
280 | os << s.substr(start,stringLen) << std::endl;
281 |
282 | // so we don't start a line with a space
283 | while ( s[stringLen+start] == ' ' && start < len )
284 | start++;
285 |
286 | start += stringLen;
287 | }
288 | }
289 | else
290 | {
291 | for ( int i = 0; i < indentSpaces; i++ )
292 | os << " ";
293 | os << s << std::endl;
294 | }
295 | }
296 |
297 | } //namespace TCLAP
298 | #endif
299 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/SwitchArg.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: SwitchArg.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot .
7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 |
24 | #ifndef TCLAP_SWITCH_ARG_H
25 | #define TCLAP_SWITCH_ARG_H
26 |
27 | #include
28 | #include
29 |
30 | #include "Arg.h"
31 |
32 | namespace TCLAP {
33 |
34 | /**
35 | * A simple switch argument. If the switch is set on the command line, then
36 | * the getValue method will return the opposite of the default value for the
37 | * switch.
38 | */
39 | class SwitchArg : public Arg
40 | {
41 | protected:
42 |
43 | /**
44 | * The value of the switch.
45 | */
46 | bool _value;
47 |
48 | /**
49 | * Used to support the reset() method so that ValueArg can be
50 | * reset to their constructed value.
51 | */
52 | bool _default;
53 |
54 | public:
55 |
56 | /**
57 | * SwitchArg constructor.
58 | * \param flag - The one character flag that identifies this
59 | * argument on the command line.
60 | * \param name - A one word name for the argument. Can be
61 | * used as a long flag on the command line.
62 | * \param desc - A description of what the argument is for or
63 | * does.
64 | * \param def - The default value for this Switch.
65 | * \param v - An optional visitor. You probably should not
66 | * use this unless you have a very good reason.
67 | */
68 | SwitchArg(const std::string& flag,
69 | const std::string& name,
70 | const std::string& desc,
71 | bool def = false,
72 | Visitor* v = NULL);
73 |
74 |
75 | /**
76 | * SwitchArg constructor.
77 | * \param flag - The one character flag that identifies this
78 | * argument on the command line.
79 | * \param name - A one word name for the argument. Can be
80 | * used as a long flag on the command line.
81 | * \param desc - A description of what the argument is for or
82 | * does.
83 | * \param parser - A CmdLine parser object to add this Arg to
84 | * \param def - The default value for this Switch.
85 | * \param v - An optional visitor. You probably should not
86 | * use this unless you have a very good reason.
87 | */
88 | SwitchArg(const std::string& flag,
89 | const std::string& name,
90 | const std::string& desc,
91 | CmdLineInterface& parser,
92 | bool def = false,
93 | Visitor* v = NULL);
94 |
95 |
96 | /**
97 | * Handles the processing of the argument.
98 | * This re-implements the Arg version of this method to set the
99 | * _value of the argument appropriately.
100 | * \param i - Pointer the the current argument in the list.
101 | * \param args - Mutable list of strings. Passed
102 | * in from main().
103 | */
104 | virtual bool processArg(int* i, std::vector& args);
105 |
106 | /**
107 | * Checks a string to see if any of the chars in the string
108 | * match the flag for this Switch.
109 | */
110 | bool combinedSwitchesMatch(std::string& combined);
111 |
112 | /**
113 | * Returns bool, whether or not the switch has been set.
114 | */
115 | bool getValue();
116 |
117 | virtual void reset();
118 |
119 | private:
120 | /**
121 | * Checks to see if we've found the last match in
122 | * a combined string.
123 | */
124 | bool lastCombined(std::string& combined);
125 |
126 | /**
127 | * Does the common processing of processArg.
128 | */
129 | void commonProcessing();
130 | };
131 |
132 | //////////////////////////////////////////////////////////////////////
133 | //BEGIN SwitchArg.cpp
134 | //////////////////////////////////////////////////////////////////////
135 | inline SwitchArg::SwitchArg(const std::string& flag,
136 | const std::string& name,
137 | const std::string& desc,
138 | bool default_val,
139 | Visitor* v )
140 | : Arg(flag, name, desc, false, false, v),
141 | _value( default_val ),
142 | _default( default_val )
143 | { }
144 |
145 | inline SwitchArg::SwitchArg(const std::string& flag,
146 | const std::string& name,
147 | const std::string& desc,
148 | CmdLineInterface& parser,
149 | bool default_val,
150 | Visitor* v )
151 | : Arg(flag, name, desc, false, false, v),
152 | _value( default_val ),
153 | _default(default_val)
154 | {
155 | parser.add( this );
156 | }
157 |
158 | inline bool SwitchArg::getValue() { return _value; }
159 |
160 | inline bool SwitchArg::lastCombined(std::string& combinedSwitches )
161 | {
162 | for ( unsigned int i = 1; i < combinedSwitches.length(); i++ )
163 | if ( combinedSwitches[i] != Arg::blankChar() )
164 | return false;
165 |
166 | return true;
167 | }
168 |
169 | inline bool SwitchArg::combinedSwitchesMatch(std::string& combinedSwitches )
170 | {
171 | // make sure this is actually a combined switch
172 | if ( combinedSwitches.length() > 0 &&
173 | combinedSwitches[0] != Arg::flagStartString()[0] )
174 | return false;
175 |
176 | // make sure it isn't a long name
177 | if ( combinedSwitches.substr( 0, Arg::nameStartString().length() ) ==
178 | Arg::nameStartString() )
179 | return false;
180 |
181 | // make sure the delimiter isn't in the string
182 | if ( combinedSwitches.find_first_of( Arg::delimiter() ) != std::string::npos )
183 | return false;
184 |
185 | // ok, we're not specifying a ValueArg, so we know that we have
186 | // a combined switch list.
187 | for ( unsigned int i = 1; i < combinedSwitches.length(); i++ )
188 | if ( _flag.length() > 0 &&
189 | combinedSwitches[i] == _flag[0] &&
190 | _flag[0] != Arg::flagStartString()[0] )
191 | {
192 | // update the combined switches so this one is no longer present
193 | // this is necessary so that no unlabeled args are matched
194 | // later in the processing.
195 | //combinedSwitches.erase(i,1);
196 | combinedSwitches[i] = Arg::blankChar();
197 | return true;
198 | }
199 |
200 | // none of the switches passed in the list match.
201 | return false;
202 | }
203 |
204 | inline void SwitchArg::commonProcessing()
205 | {
206 | if ( _xorSet )
207 | throw(CmdLineParseException(
208 | "Mutually exclusive argument already set!", toString()));
209 |
210 | if ( _alreadySet )
211 | throw(CmdLineParseException("Argument already set!", toString()));
212 |
213 | _alreadySet = true;
214 |
215 | if ( _value == true )
216 | _value = false;
217 | else
218 | _value = true;
219 |
220 | _checkWithVisitor();
221 | }
222 |
223 | inline bool SwitchArg::processArg(int *i, std::vector& args)
224 | {
225 | if ( _ignoreable && Arg::ignoreRest() )
226 | return false;
227 |
228 | // if the whole string matches the flag or name string
229 | if ( argMatches( args[*i] ) )
230 | {
231 | commonProcessing();
232 |
233 | return true;
234 | }
235 | // if a substring matches the flag as part of a combination
236 | else if ( combinedSwitchesMatch( args[*i] ) )
237 | {
238 | // check again to ensure we don't misinterpret
239 | // this as a MultiSwitchArg
240 | if ( combinedSwitchesMatch( args[*i] ) )
241 | throw(CmdLineParseException("Argument already set!",
242 | toString()));
243 |
244 | commonProcessing();
245 |
246 | // We only want to return true if we've found the last combined
247 | // match in the string, otherwise we return true so that other
248 | // switches in the combination will have a chance to match.
249 | return lastCombined( args[*i] );
250 | }
251 | else
252 | return false;
253 | }
254 |
255 | inline void SwitchArg::reset()
256 | {
257 | Arg::reset();
258 | _value = _default;
259 | }
260 | //////////////////////////////////////////////////////////////////////
261 | //End SwitchArg.cpp
262 | //////////////////////////////////////////////////////////////////////
263 |
264 | } //namespace TCLAP
265 |
266 | #endif
267 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/UnlabeledMultiArg.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: UnlabeledMultiArg.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot.
7 | * All rights reverved.
8 | *
9 | * See the file COPYING in the top directory of this distribution for
10 | * more information.
11 | *
12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 | * DEALINGS IN THE SOFTWARE.
19 | *
20 | *****************************************************************************/
21 |
22 |
23 | #ifndef TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H
24 | #define TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H
25 |
26 | #include
27 | #include
28 |
29 | #include "MultiArg.h"
30 | #include "OptionalUnlabeledTracker.h"
31 |
32 | namespace TCLAP {
33 |
34 | /**
35 | * Just like a MultiArg, except that the arguments are unlabeled. Basically,
36 | * this Arg will slurp up everything that hasn't been matched to another
37 | * Arg.
38 | */
39 | template
40 | class UnlabeledMultiArg : public MultiArg
41 | {
42 |
43 | // If compiler has two stage name lookup (as gcc >= 3.4 does)
44 | // this is requried to prevent undef. symbols
45 | using MultiArg::_ignoreable;
46 | using MultiArg::_hasBlanks;
47 | using MultiArg::_extractValue;
48 | using MultiArg::_typeDesc;
49 | using MultiArg::_name;
50 | using MultiArg::_description;
51 | using MultiArg::_alreadySet;
52 | using MultiArg::toString;
53 |
54 | public:
55 |
56 | /**
57 | * Constructor.
58 | * \param name - The name of the Arg. Note that this is used for
59 | * identification, not as a long flag.
60 | * \param desc - A description of what the argument is for or
61 | * does.
62 | * \param req - Whether the argument is required on the command
63 | * line.
64 | * \param typeDesc - A short, human readable description of the
65 | * type that this object expects. This is used in the generation
66 | * of the USAGE statement. The goal is to be helpful to the end user
67 | * of the program.
68 | * \param ignoreable - Whether or not this argument can be ignored
69 | * using the "--" flag.
70 | * \param v - An optional visitor. You probably should not
71 | * use this unless you have a very good reason.
72 | */
73 | UnlabeledMultiArg( const std::string& name,
74 | const std::string& desc,
75 | bool req,
76 | const std::string& typeDesc,
77 | bool ignoreable = false,
78 | Visitor* v = NULL );
79 | /**
80 | * Constructor.
81 | * \param name - The name of the Arg. Note that this is used for
82 | * identification, not as a long flag.
83 | * \param desc - A description of what the argument is for or
84 | * does.
85 | * \param req - Whether the argument is required on the command
86 | * line.
87 | * \param typeDesc - A short, human readable description of the
88 | * type that this object expects. This is used in the generation
89 | * of the USAGE statement. The goal is to be helpful to the end user
90 | * of the program.
91 | * \param parser - A CmdLine parser object to add this Arg to
92 | * \param ignoreable - Whether or not this argument can be ignored
93 | * using the "--" flag.
94 | * \param v - An optional visitor. You probably should not
95 | * use this unless you have a very good reason.
96 | */
97 | UnlabeledMultiArg( const std::string& name,
98 | const std::string& desc,
99 | bool req,
100 | const std::string& typeDesc,
101 | CmdLineInterface& parser,
102 | bool ignoreable = false,
103 | Visitor* v = NULL );
104 |
105 | /**
106 | * Constructor.
107 | * \param name - The name of the Arg. Note that this is used for
108 | * identification, not as a long flag.
109 | * \param desc - A description of what the argument is for or
110 | * does.
111 | * \param req - Whether the argument is required on the command
112 | * line.
113 | * \param constraint - A pointer to a Constraint object used
114 | * to constrain this Arg.
115 | * \param ignoreable - Whether or not this argument can be ignored
116 | * using the "--" flag.
117 | * \param v - An optional visitor. You probably should not
118 | * use this unless you have a very good reason.
119 | */
120 | UnlabeledMultiArg( const std::string& name,
121 | const std::string& desc,
122 | bool req,
123 | Constraint* constraint,
124 | bool ignoreable = false,
125 | Visitor* v = NULL );
126 |
127 | /**
128 | * Constructor.
129 | * \param name - The name of the Arg. Note that this is used for
130 | * identification, not as a long flag.
131 | * \param desc - A description of what the argument is for or
132 | * does.
133 | * \param req - Whether the argument is required on the command
134 | * line.
135 | * \param constraint - A pointer to a Constraint object used
136 | * to constrain this Arg.
137 | * \param parser - A CmdLine parser object to add this Arg to
138 | * \param ignoreable - Whether or not this argument can be ignored
139 | * using the "--" flag.
140 | * \param v - An optional visitor. You probably should not
141 | * use this unless you have a very good reason.
142 | */
143 | UnlabeledMultiArg( const std::string& name,
144 | const std::string& desc,
145 | bool req,
146 | Constraint* constraint,
147 | CmdLineInterface& parser,
148 | bool ignoreable = false,
149 | Visitor* v = NULL );
150 |
151 | /**
152 | * Handles the processing of the argument.
153 | * This re-implements the Arg version of this method to set the
154 | * _value of the argument appropriately. It knows the difference
155 | * between labeled and unlabeled.
156 | * \param i - Pointer the the current argument in the list.
157 | * \param args - Mutable list of strings. Passed from main().
158 | */
159 | virtual bool processArg(int* i, std::vector& args);
160 |
161 | /**
162 | * Returns the a short id string. Used in the usage.
163 | * \param val - value to be used.
164 | */
165 | virtual std::string shortID(const std::string& val="val") const;
166 |
167 | /**
168 | * Returns the a long id string. Used in the usage.
169 | * \param val - value to be used.
170 | */
171 | virtual std::string longID(const std::string& val="val") const;
172 |
173 | /**
174 | * Opertor ==.
175 | * \param a - The Arg to be compared to this.
176 | */
177 | virtual bool operator==(const Arg& a) const;
178 |
179 | /**
180 | * Pushes this to back of list rather than front.
181 | * \param argList - The list this should be added to.
182 | */
183 | virtual void addToList( std::list& argList ) const;
184 | };
185 |
186 | template
187 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name,
188 | const std::string& desc,
189 | bool req,
190 | const std::string& typeDesc,
191 | bool ignoreable,
192 | Visitor* v)
193 | : MultiArg("", name, desc, req, typeDesc, v)
194 | {
195 | _ignoreable = ignoreable;
196 | OptionalUnlabeledTracker::check(true, toString());
197 | }
198 |
199 | template
200 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name,
201 | const std::string& desc,
202 | bool req,
203 | const std::string& typeDesc,
204 | CmdLineInterface& parser,
205 | bool ignoreable,
206 | Visitor* v)
207 | : MultiArg("", name, desc, req, typeDesc, v)
208 | {
209 | _ignoreable = ignoreable;
210 | OptionalUnlabeledTracker::check(true, toString());
211 | parser.add( this );
212 | }
213 |
214 |
215 | template
216 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name,
217 | const std::string& desc,
218 | bool req,
219 | Constraint* constraint,
220 | bool ignoreable,
221 | Visitor* v)
222 | : MultiArg("", name, desc, req, constraint, v)
223 | {
224 | _ignoreable = ignoreable;
225 | OptionalUnlabeledTracker::check(true, toString());
226 | }
227 |
228 | template
229 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name,
230 | const std::string& desc,
231 | bool req,
232 | Constraint* constraint,
233 | CmdLineInterface& parser,
234 | bool ignoreable,
235 | Visitor* v)
236 | : MultiArg("", name, desc, req, constraint, v)
237 | {
238 | _ignoreable = ignoreable;
239 | OptionalUnlabeledTracker::check(true, toString());
240 | parser.add( this );
241 | }
242 |
243 |
244 | template
245 | bool UnlabeledMultiArg::processArg(int *i, std::vector& args)
246 | {
247 |
248 | if ( _hasBlanks( args[*i] ) )
249 | return false;
250 |
251 | // never ignore an unlabeled multi arg
252 |
253 |
254 | // always take the first value, regardless of the start string
255 | _extractValue( args[(*i)] );
256 |
257 | /*
258 | // continue taking args until we hit the end or a start string
259 | while ( (unsigned int)(*i)+1 < args.size() &&
260 | args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 &&
261 | args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 )
262 | _extractValue( args[++(*i)] );
263 | */
264 |
265 | _alreadySet = true;
266 |
267 | return true;
268 | }
269 |
270 | template
271 | std::string UnlabeledMultiArg::shortID(const std::string& val) const
272 | {
273 | static_cast(val); // Ignore input, don't warn
274 | return std::string("<") + _typeDesc + "> ...";
275 | }
276 |
277 | template
278 | std::string UnlabeledMultiArg::longID(const std::string& val) const
279 | {
280 | static_cast(val); // Ignore input, don't warn
281 | return std::string("<") + _typeDesc + "> (accepted multiple times)";
282 | }
283 |
284 | template
285 | bool UnlabeledMultiArg::operator==(const Arg& a) const
286 | {
287 | if ( _name == a.getName() || _description == a.getDescription() )
288 | return true;
289 | else
290 | return false;
291 | }
292 |
293 | template
294 | void UnlabeledMultiArg::addToList( std::list& argList ) const
295 | {
296 | argList.push_back( const_cast(static_cast(this)) );
297 | }
298 |
299 | }
300 |
301 | #endif
302 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/ValuesConstraint.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /******************************************************************************
4 | *
5 | * file: ValuesConstraint.h
6 | *
7 | * Copyright (c) 2005, Michael E. Smoot
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 | #ifndef TCLAP_VALUESCONSTRAINT_H
24 | #define TCLAP_VALUESCONSTRAINT_H
25 |
26 | #include
27 | #include
28 | #include "Constraint.h"
29 |
30 | #ifdef HAVE_CONFIG_H
31 | #include
32 | #else
33 | #define HAVE_SSTREAM
34 | #endif
35 |
36 | #if defined(HAVE_SSTREAM)
37 | #include
38 | #elif defined(HAVE_STRSTREAM)
39 | #include
40 | #else
41 | #error "Need a stringstream (sstream or strstream) to compile!"
42 | #endif
43 |
44 | namespace TCLAP {
45 |
46 | /**
47 | * A Constraint that constrains the Arg to only those values specified
48 | * in the constraint.
49 | */
50 | template
51 | class ValuesConstraint : public Constraint
52 | {
53 |
54 | public:
55 |
56 | /**
57 | * Constructor.
58 | * \param allowed - vector of allowed values.
59 | */
60 | ValuesConstraint(std::vector& allowed);
61 |
62 | /**
63 | * Virtual destructor.
64 | */
65 | virtual ~ValuesConstraint() {}
66 |
67 | /**
68 | * Returns a description of the Constraint.
69 | */
70 | virtual std::string description() const;
71 |
72 | /**
73 | * Returns the short ID for the Constraint.
74 | */
75 | virtual std::string shortID() const;
76 |
77 | /**
78 | * The method used to verify that the value parsed from the command
79 | * line meets the constraint.
80 | * \param value - The value that will be checked.
81 | */
82 | virtual bool check(const T& value) const;
83 |
84 | protected:
85 |
86 | /**
87 | * The list of valid values.
88 | */
89 | std::vector _allowed;
90 |
91 | /**
92 | * The string used to describe the allowed values of this constraint.
93 | */
94 | std::string _typeDesc;
95 |
96 | };
97 |
98 | template
99 | ValuesConstraint::ValuesConstraint(std::vector& allowed)
100 | : _allowed(allowed),
101 | _typeDesc("")
102 | {
103 | for ( unsigned int i = 0; i < _allowed.size(); i++ )
104 | {
105 |
106 | #if defined(HAVE_SSTREAM)
107 | std::ostringstream os;
108 | #elif defined(HAVE_STRSTREAM)
109 | std::ostrstream os;
110 | #else
111 | #error "Need a stringstream (sstream or strstream) to compile!"
112 | #endif
113 |
114 | os << _allowed[i];
115 |
116 | std::string temp( os.str() );
117 |
118 | if ( i > 0 )
119 | _typeDesc += "|";
120 | _typeDesc += temp;
121 | }
122 | }
123 |
124 | template
125 | bool ValuesConstraint::check( const T& val ) const
126 | {
127 | if ( std::find(_allowed.begin(),_allowed.end(),val) == _allowed.end() )
128 | return false;
129 | else
130 | return true;
131 | }
132 |
133 | template
134 | std::string ValuesConstraint::shortID() const
135 | {
136 | return _typeDesc;
137 | }
138 |
139 | template
140 | std::string ValuesConstraint::description() const
141 | {
142 | return _typeDesc;
143 | }
144 |
145 |
146 | } //namespace TCLAP
147 | #endif
148 |
149 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/VersionVisitor.h:
--------------------------------------------------------------------------------
1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2 |
3 | /******************************************************************************
4 | *
5 | * file: VersionVisitor.h
6 | *
7 | * Copyright (c) 2003, Michael E. Smoot .
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 |
24 | #ifndef TCLAP_VERSION_VISITOR_H
25 | #define TCLAP_VERSION_VISITOR_H
26 |
27 | #include "CmdLineInterface.h"
28 | #include "CmdLineOutput.h"
29 | #include "Visitor.h"
30 |
31 | namespace TCLAP {
32 |
33 | /**
34 | * A Vistor that will call the version method of the given CmdLineOutput
35 | * for the specified CmdLine object and then exit.
36 | */
37 | class VersionVisitor: public Visitor
38 | {
39 | private:
40 | /**
41 | * Prevent accidental copying
42 | */
43 | VersionVisitor(const VersionVisitor& rhs);
44 | VersionVisitor& operator=(const VersionVisitor& rhs);
45 |
46 | protected:
47 |
48 | /**
49 | * The CmdLine of interest.
50 | */
51 | CmdLineInterface* _cmd;
52 |
53 | /**
54 | * The output object.
55 | */
56 | CmdLineOutput** _out;
57 |
58 | public:
59 |
60 | /**
61 | * Constructor.
62 | * \param cmd - The CmdLine the output is generated for.
63 | * \param out - The type of output.
64 | */
65 | VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out )
66 | : Visitor(), _cmd( cmd ), _out( out ) { }
67 |
68 | /**
69 | * Calls the version method of the output object using the
70 | * specified CmdLine.
71 | */
72 | void visit() {
73 | (*_out)->version(*_cmd);
74 | throw ExitException(0);
75 | }
76 |
77 | };
78 |
79 | }
80 |
81 | #endif
82 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/Visitor.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: Visitor.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot .
7 | * All rights reverved.
8 | *
9 | * See the file COPYING in the top directory of this distribution for
10 | * more information.
11 | *
12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 | * DEALINGS IN THE SOFTWARE.
19 | *
20 | *****************************************************************************/
21 |
22 |
23 | #ifndef TCLAP_VISITOR_H
24 | #define TCLAP_VISITOR_H
25 |
26 | namespace TCLAP {
27 |
28 | /**
29 | * A base class that defines the interface for visitors.
30 | */
31 | class Visitor
32 | {
33 | public:
34 |
35 | /**
36 | * Constructor. Does nothing.
37 | */
38 | Visitor() { }
39 |
40 | /**
41 | * Destructor. Does nothing.
42 | */
43 | virtual ~Visitor() { }
44 |
45 | /**
46 | * Does nothing. Should be overridden by child.
47 | */
48 | virtual void visit() { }
49 | };
50 |
51 | }
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/XorHandler.h:
--------------------------------------------------------------------------------
1 |
2 | /******************************************************************************
3 | *
4 | * file: XorHandler.h
5 | *
6 | * Copyright (c) 2003, Michael E. Smoot .
7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 | #ifndef TCLAP_XORHANDLER_H
24 | #define TCLAP_XORHANDLER_H
25 |
26 | #include "Arg.h"
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | namespace TCLAP {
33 |
34 | /**
35 | * This class handles lists of Arg's that are to be XOR'd on the command
36 | * line. This is used by CmdLine and you shouldn't ever use it.
37 | */
38 | class XorHandler
39 | {
40 | protected:
41 |
42 | /**
43 | * The list of of lists of Arg's to be or'd together.
44 | */
45 | std::vector< std::vector > _orList;
46 |
47 | public:
48 |
49 | /**
50 | * Constructor. Does nothing.
51 | */
52 | XorHandler( ) : _orList(std::vector< std::vector >()) {}
53 |
54 | /**
55 | * Add a list of Arg*'s that will be orred together.
56 | * \param ors - list of Arg* that will be xor'd.
57 | */
58 | void add( std::vector& ors );
59 |
60 | /**
61 | * Checks whether the specified Arg is in one of the xor lists and
62 | * if it does match one, returns the size of the xor list that the
63 | * Arg matched. If the Arg matches, then it also sets the rest of
64 | * the Arg's in the list. You shouldn't use this.
65 | * \param a - The Arg to be checked.
66 | */
67 | int check( const Arg* a );
68 |
69 | /**
70 | * Returns the XOR specific short usage.
71 | */
72 | std::string shortUsage();
73 |
74 | /**
75 | * Prints the XOR specific long usage.
76 | * \param os - Stream to print to.
77 | */
78 | void printLongUsage(std::ostream& os);
79 |
80 | /**
81 | * Simply checks whether the Arg is contained in one of the arg
82 | * lists.
83 | * \param a - The Arg to be checked.
84 | */
85 | bool contains( const Arg* a );
86 |
87 | std::vector< std::vector >& getXorList();
88 |
89 | };
90 |
91 |
92 | //////////////////////////////////////////////////////////////////////
93 | //BEGIN XOR.cpp
94 | //////////////////////////////////////////////////////////////////////
95 | inline void XorHandler::add( std::vector& ors )
96 | {
97 | _orList.push_back( ors );
98 | }
99 |
100 | inline int XorHandler::check( const Arg* a )
101 | {
102 | // iterate over each XOR list
103 | for ( int i = 0; static_cast(i) < _orList.size(); i++ )
104 | {
105 | // if the XOR list contains the arg..
106 | ArgVectorIterator ait = std::find( _orList[i].begin(),
107 | _orList[i].end(), a );
108 | if ( ait != _orList[i].end() )
109 | {
110 | // first check to see if a mutually exclusive switch
111 | // has not already been set
112 | for ( ArgVectorIterator it = _orList[i].begin();
113 | it != _orList[i].end();
114 | it++ )
115 | if ( a != (*it) && (*it)->isSet() )
116 | throw(CmdLineParseException(
117 | "Mutually exclusive argument already set!",
118 | (*it)->toString()));
119 |
120 | // go through and set each arg that is not a
121 | for ( ArgVectorIterator it = _orList[i].begin();
122 | it != _orList[i].end();
123 | it++ )
124 | if ( a != (*it) )
125 | (*it)->xorSet();
126 |
127 | // return the number of required args that have now been set
128 | if ( (*ait)->allowMore() )
129 | return 0;
130 | else
131 | return static_cast(_orList[i].size());
132 | }
133 | }
134 |
135 | if ( a->isRequired() )
136 | return 1;
137 | else
138 | return 0;
139 | }
140 |
141 | inline bool XorHandler::contains( const Arg* a )
142 | {
143 | for ( int i = 0; static_cast(i) < _orList.size(); i++ )
144 | for ( ArgVectorIterator it = _orList[i].begin();
145 | it != _orList[i].end();
146 | it++ )
147 | if ( a == (*it) )
148 | return true;
149 |
150 | return false;
151 | }
152 |
153 | inline std::vector< std::vector >& XorHandler::getXorList()
154 | {
155 | return _orList;
156 | }
157 |
158 |
159 |
160 | //////////////////////////////////////////////////////////////////////
161 | //END XOR.cpp
162 | //////////////////////////////////////////////////////////////////////
163 |
164 | } //namespace TCLAP
165 |
166 | #endif
167 |
--------------------------------------------------------------------------------
/components/mkspiffs/src/tclap/ZshCompletionOutput.h:
--------------------------------------------------------------------------------
1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2 |
3 | /******************************************************************************
4 | *
5 | * file: ZshCompletionOutput.h
6 | *
7 | * Copyright (c) 2006, Oliver Kiddle
8 | * All rights reverved.
9 | *
10 | * See the file COPYING in the top directory of this distribution for
11 | * more information.
12 | *
13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | * DEALINGS IN THE SOFTWARE.
20 | *
21 | *****************************************************************************/
22 |
23 | #ifndef TCLAP_ZSHCOMPLETIONOUTPUT_H
24 | #define TCLAP_ZSHCOMPLETIONOUTPUT_H
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include