Bonjour, j'aimerais créer une librairie (.a) à partir des fichiers suivants (je vous donne que les fichiers.h mais ne les lisez pas encore...):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 #ifndef FUNCTION_H_INCLUDED #define FUNCTION_H_INCLUDED #include <vector> #include <string> struct Variables; struct fc_functions; struct couple; namespace mp { class function { private : std::string fc; std::string simplified_fc; std::string result; std::vector<fc_function> sub_functions; Variables my_variables; bool is_simplified; void get_simplified_fc(); void add_operators(); void erase_spaces(); unsigned int is_variable_or_function(std::string , unsigned int); bool is_sub_function(std::string, unsigned int); void put_parentheses_around_operator(std::string, unsigned int); void put_parentheses_around_functions(); void add_parentheses(); unsigned int pos_end(std::string chn); void replace(); std::string execute(std::string); bool has_sub_function(std::string chn); public : void add_sub_functions(std::vector<fc_function>); void add_sub_functions(fc_function); function(std::string, bool=true); std::string calculate(); void add_variable(couple); void set_value(std::string variable,double value); }; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #ifndef OTHER_CLASSES_H_INCLUDED #define OTHER_CLASSES_H_INCLUDED #include <string> #include<vector> struct couple { double num; std::string str; couple(std::string n, double val=0):str(n),num(val){}; }; struct Variables { public : std::vector<couple> variables; void add(couple v){variables.push_back(v);} bool put_behind_parentheses(std::string& , unsigned int ); bool put_in_front_parentheses(std::string& , unsigned int ); unsigned int get_v(std::string chn); }; #endif // OTHER_CLASSES_H_INCLUDED
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #ifndef FC_FUNCTION_H_INCLUDED #define FC_FUNCTION_H_INCLUDED #include <vector> #include <string> struct couple; namespace mp { struct fc_function { std::string name; double (*fc1)(double); double (*fc2)(std::vector<double>); fc_function(std::string n, double (*fc)(double), double (*fc_2)(std::vector<double>)=do_nothing); fc_function(std::string n, double (*fc_2)(std::vector<double>)); }; double max(std::vector<double>); std::string from_double(double ); double to_double (std::string chn); double min(std::vector<double>); double my_log(std::vector<double>); double my_exp(std::vector<double>); } #endif // FC_FUNCTION_H_INCLUDEDJe me rend bien compte que ces .h sont pas bien beaux (il manque les const...)mais j'aimerais pouvoir créer une librairie telle que les fichiers needed_functions.h et other_classes.h soient transparents
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #ifndef NEEDED_FUNCTIONS_H_INCLUDED #define NEEDED_FUNCTIONS_H_INCLUDED #include <vector> #include <string> bool is_number(char); double do_nothing(std::vector<double>); double do_nothing(double); unsigned int pos_end(std::string); void add_after_close_parentheses(unsigned int ,std::string& ); void add_before_open_parentheses(std::string& ,unsigned int ); bool is_number_or_parentheses(char); unsigned int find_operator(std::string); double get_number_from_operator(double ,char ,double ); unsigned int get_occurence(std::string chn, char c); unsigned int get_first_number(std::string chn); #endif // NEEDED_FUNCTIONS_H_INCLUDED
(c'est à dire que les classes Variables et couple n'existent pas aux yeux de l'utilisateur (bien sur, il faut que functions.cpp puisse les utiliser).
Comment faire pour générer une nouvelle librairie (c'est ma première librairie que je créée)?
Partager