diff options
Diffstat (limited to 'oop2eindopdr')
-rw-r--r-- | oop2eindopdr/.gitignore | 1 | ||||
-rw-r--r-- | oop2eindopdr/input.csv | 21 | ||||
-rw-r--r-- | oop2eindopdr/main.cpp | 34 | ||||
-rw-r--r-- | oop2eindopdr/makefile | 28 | ||||
-rw-r--r-- | oop2eindopdr/readme.md | 93 |
5 files changed, 177 insertions, 0 deletions
diff --git a/oop2eindopdr/.gitignore b/oop2eindopdr/.gitignore new file mode 100644 index 0000000..06cf653 --- /dev/null +++ b/oop2eindopdr/.gitignore @@ -0,0 +1 @@ +cache diff --git a/oop2eindopdr/input.csv b/oop2eindopdr/input.csv new file mode 100644 index 0000000..1b8f133 --- /dev/null +++ b/oop2eindopdr/input.csv @@ -0,0 +1,21 @@ +id +swshp-SWSH001 +swshp-SWSH002 +swshp-SWSH003 +swshp-SWSH004 +swshp-SWSH005 +swshp-SWSH006 +swshp-SWSH007 +swshp-SWSH008 +swshp-SWSH009 +swshp-SWSH010 +swshp-SWSH011 +swshp-SWSH012 +swshp-SWSH013 +swshp-SWSH014 +swshp-SWSH015 +swshp-SWSH016 +swshp-SWSH017 +swshp-SWSH018 +swshp-SWSH019 +swshp-SWSH020 diff --git a/oop2eindopdr/main.cpp b/oop2eindopdr/main.cpp new file mode 100644 index 0000000..5eb8beb --- /dev/null +++ b/oop2eindopdr/main.cpp @@ -0,0 +1,34 @@ +#include <cstdlib> +#include <iostream> + +using std::endl; +using std::cout; + +int interactive_mode() { + std::string gert; + bool user_exit = false; + while (!user_exit) { + cout << "interactive mode" << endl; + std::cin >> gert; + } + return EXIT_SUCCESS; +} + +int export_mode(int argc, char** argv) { + cout << "export mode! let's convert " << std::string(argv[1]) << " to " << std::string(argv[2]) << endl; + + return EXIT_SUCCESS; +} + +int main(int argc, char** argv) { + if (argc == 1) { // no arguments specified + return interactive_mode(); + } else if (argc == 2 || argc == 3) { + return export_mode(argc, argv); + } else { // three or more arguments + cout << "too many arguments specified!" << endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/oop2eindopdr/makefile b/oop2eindopdr/makefile new file mode 100644 index 0000000..a4235d4 --- /dev/null +++ b/oop2eindopdr/makefile @@ -0,0 +1,28 @@ +CC = g++ +LD = g++ +RM = rm -f +TARGET = main +OUTPUT_ZIP = Eindopdracht_2180996.zip + +LFLAGS += -lstdc++ + +SRCS := $(wildcard *.cpp) +OBJS := $(patsubst %.cpp,%.o, $(SRCS)) + +all: $(TARGET) + +%.o: %.cpp + $(CC) -c $(CFLAGS) $< -o $@ + +$(TARGET): $(OBJS) + $(LD) $^ $(LFLAGS) -o $@ + +clean: + $(RM) $(TARGET) $(OBJS) $(OUTPUT_ZIP) + +compile_commands: clean + compiledb make + +zip: all + zip -q $(OUTPUT_ZIP) makefile $(wildcard *.cpp) $(wildcard *.h) $(wildcard *.hpp) + diff --git a/oop2eindopdr/readme.md b/oop2eindopdr/readme.md new file mode 100644 index 0000000..d423e78 --- /dev/null +++ b/oop2eindopdr/readme.md @@ -0,0 +1,93 @@ +# eindopdracht + +combinatie readme en kladblok tijdens ontwikkeling + +## gebruikte libraries + +- versies moeten nog gedocumenteerd worden +- er wordt er vanuit gegaan dat deze libraries als systeemheaders geïnstalleerd + zijn + +- [nlohmann/json](https://github.com/nlohmann/json) voor json (de)serializen +- [cpr](https://github.com/libcpr/cpr) voor https requests +- [libzip](https://libzip.org/) voor zip bestanden maken +- [csv2](https://github.com/p-ranav/csv2) voor csv bestanden (de)serializen + +## functionaliteit (pseudocode) + +``` +parse_cli_arguments() +init_update_cache() +case cli_argument.count + 0: // no arguments (interactive mode) + while 1: + id = input_text("card id?: ") + list = filter_card_list(id) + if list.count > 1: + card = choose_single_card() + else: + card = list[0] + display_card_with_value_info(card) + 1, 2: // input csv with optional output json (semi-interactive mode) + ids = parse_csv() + cards = [] + for id in ids: + card = get_card_by_id(id) + display_card(card) + cards += card; + if cli_argument.count == 2: + export_cards_as_zip(cli_argument[0]) + else if input_yn("export? [Y/n]: "): + output_filename = input_text("export filename?: ") + export_cards_as_zip(output_filename) + +``` + +## cache formaat (voorbeeld) + +``` +cache/ + date + swshp-SWSH001/ + info.json + card.png + card_hires.png + swshp-SWSH002/ + info.json + card.png + card_hires.png + swshp-SWSH..../ +``` + +- `date` bevat een unix timestamp wanneer de cache voor het laatst geupdate is + (gebruikt om te checken of de cache stale is) +- `info.json` bevat voor elke kaart de json api response voor die kaart + +## zip formaat (voorbeeld) + +``` +output.zip/ + cards.csv + swshp-SWSH001.png + swshp-SWSH002.png + swshp-SWSH.... +``` + +- `cat cards.csv`: + ``` + id,value + swshp-SWSH001,3.00 + swshp-SWSH002,2.59 + swshp-SWSH.... + ``` + (punt voor decimale punt inplaats van komma) +- de kaart foto's zijn de -hires variant + +## klassen (wip) + +- PokemonCard +- PokemonTCGAPIClient +- CacheManager +- DownloadManager +- ZipExport + |