cgv
Loading...
Searching...
No Matches
import.h
1#pragma once
2
3#include <string>
4#include <vector>
5
6#include "lib_begin.h"
7
9namespace cgv {
11 namespace base {
12
14extern CGV_API void push_file_parent(const std::string& path_or_file_name);
15
17extern CGV_API void pop_file_parent();
18
39extern CGV_API std::string find_data_file(const std::string& file_name, const std::string& strategy, const std::string& sub_directory = "", const std::string& master_path = "");
40
41
43extern CGV_API void stdout_message(const std::string& text);
44
46extern CGV_API void stderr_message(const std::string& text);
47
49extern CGV_API int std_query(const std::string& text, const std::string& answers, int default_answer);
50
52extern CGV_API std::string std_ask_dir(const std::string& text, const std::string& path);
53
56{
58 void (*message)(const std::string& text);
60 int (*query)(const std::string& text, const std::string& answers, int default_answer);
62 std::string(*ask_dir)(const std::string& text, const std::string& path);
65 void (*_message)(const std::string&) = 0,
66 int (*_query)(const std::string&, const std::string&, int) = 0,
67 std::string(*_ask_dir)(const std::string&, const std::string&) = 0
69 {}
70};
71
83extern CGV_API std::string find_or_download_data_file(const std::string& file_name, const std::string& find_strategy,
84 const std::string& url, const std::string& cache_strategy, const std::string& producer,
85 const std::string& sub_directory = "", const std::string& master_path = "", user_feedback uf = user_feedback());
86
88extern CGV_API std::vector<std::string>& ref_data_path_list();
89
91extern CGV_API std::vector<std::string>& ref_parent_file_stack();
92
94extern CGV_API FILE* open_data_file(const std::string& file_name, const char* mode);
95
97extern CGV_API bool read_data_file(const std::string& file_name, std::string& content, bool ascii);
98
100extern CGV_API unsigned int data_file_size(const std::string& file_name);
101
103extern CGV_API unsigned int find_file_offset(const std::string& file_name, const char* data, unsigned int data_size);
104
105 }
106}
107
108#include <cgv/config/lib_end.h>
complete implementation of method actions that only call one method when entering a node
Definition action.h:113
std::string std_ask_dir(const std::string &text, const std::string &path)
std::cout and std::cin based implementation of the ask_dir function for third argument to the user_fe...
Definition import.cxx:150
std::string find_or_download_data_file(const std::string &file_name, const std::string &find_strategy, const std::string &url, const std::string &cache_strategy, const std::string &producer, const std::string &sub_directory, const std::string &master_path, user_feedback uf)
same as find_data_file() but in case file is not found, it is downloaded from the provided url and st...
Definition import.cxx:159
void stderr_message(const std::string &text)
std::cerr based implementation of the message function for first argument to the user_feedback constr...
Definition import.cxx:131
int std_query(const std::string &text, const std::string &answers, int default_answer)
std::cout and std::cin based implementation of the query function for second argument to the user_fee...
Definition import.cxx:136
unsigned int find_file_offset(const std::string &file_name, const char *data, unsigned int data_size)
find the offset of the given data block in the given file
Definition import.cxx:421
void pop_file_parent()
pop the latestly pushed parent path from the parent path stack.
Definition import.cxx:314
void push_file_parent(const std::string &path_or_file_name)
extract a valid path from the given argument and push it onto the stack of parent paths....
Definition import.cxx:295
std::vector< std::string > & ref_parent_file_stack()
return a reference to the data path list, which is constructed from the environment variable CGV_DATA
Definition import.cxx:321
bool read_data_file(const std::string &file_name, std::string &content, bool ascii)
read ascii file into a string
Definition import.cxx:388
std::vector< std::string > & ref_data_path_list()
return a reference to the data path list, which is constructed from the environment variable CGV_DATA
Definition import.cxx:274
FILE * open_data_file(const std::string &file_name, const char *mode)
open a file with fopen supporting resource files, that have the prefix "res://"
Definition import.cxx:350
std::string find_data_file(const std::string &file_name, const std::string &strategy, const std::string &sub_directory, const std::string &master_path)
Find a file with the given strategy and return the file name extended by the necessary path.
Definition import.cxx:59
unsigned int data_file_size(const std::string &file_name)
return the file size of a given file with support for resource files, that have the prefix "res://"
Definition import.cxx:413
void stdout_message(const std::string &text)
std::cout based implementation of the message function for first argument to the user_feedback constr...
Definition import.cxx:126
the cgv namespace
Definition print.h:11
function pointers implementing user feedback functionality of find_or_download_data_file() function
Definition import.h:56
void(* message)(const std::string &text)
pointer to function that shows a text message to user
Definition import.h:58
int(* query)(const std::string &text, const std::string &answers, int default_answer)
pointer to function that shows a text query and asks for an answer
Definition import.h:60
user_feedback(void(*_message)(const std::string &)=0, int(*_query)(const std::string &, const std::string &, int)=0, std::string(*_ask_dir)(const std::string &, const std::string &)=0)
default construction results in no user feedback
Definition import.h:64
std::string(* ask_dir)(const std::string &text, const std::string &path)
pointer to function that opens a directory save dialog
Definition import.h:62