ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/outil/src/ot_chaine.cpp
Revision: 775
Committed: Mon Jan 25 22:49:10 2016 UTC (9 years, 3 months ago) by francois
File size: 3114 byte(s)
Log Message:
debug conditions aux limites pour les sommets dans une geometrie virtuelle

File Contents

# User Rev Content
1 francois 708 #include "gestionversion.h"
2     #include "ot_chaine.h"
3     #include <string.h>
4 francois 773 #include <stdlib.h>
5 francois 708 #include <string>
6     #include <iostream>
7     #include <stdio.h>
8 francois 757 #include <math.h>
9 francois 775 #include <locale>
10 francois 708
11    
12    
13    
14    
15     OT_CHAINE::OT_CHAINE()
16     {
17 francois 749 transpose[0]='0';
18     transpose[1]='1';
19     transpose[2]='2';
20     transpose[3]='3';
21     transpose[4]='4';
22     transpose[5]='5';
23     transpose[6]='6';
24     transpose[7]='7';
25     transpose[8]='8';
26     transpose[9]='9';
27     transpose[10]='A';
28     transpose[11]='B';
29     transpose[12]='C';
30     transpose[13]='D';
31     transpose[14]='E';
32     transpose[15]='F';
33     transpose[16]='G';
34     transpose[17]='H';
35     transpose[18]='I';
36     transpose[19]='J';
37     transpose[20]='K';
38     transpose[21]='L';
39     transpose[22]='M';
40     transpose[23]='N';
41     transpose[24]='O';
42     transpose[25]='P';
43     transpose[26]='Q';
44     transpose[27]='R';
45     transpose[28]='S';
46     transpose[29]='T';
47     transpose[30]='U';
48     transpose[31]='V';
49     transpose[32]='W';
50     transpose[33]='X';
51     transpose[34]='Y';
52     transpose[35]='Z';
53 francois 757 digit['0']=0;
54     digit['1']=1;
55     digit['2']=2;
56     digit['3']=3;
57     digit['4']=4;
58     digit['5']=5;
59     digit['6']=6;
60     digit['7']=7;
61     digit['8']=8;
62     digit['9']=9;
63     digit['A']=10;
64     digit['B']=11;
65     digit['C']=12;
66     digit['D']=13;
67     digit['E']=14;
68     digit['F']=15;
69     digit['G']=16;
70     digit['H']=17;
71     digit['I']=18;
72     digit['J']=19;
73     digit['K']=20;
74     digit['L']=21;
75     digit['M']=22;
76     digit['N']=23;
77     digit['O']=24;
78     digit['P']=25;
79     digit['Q']=26;
80     digit['R']=27;
81     digit['S']=28;
82     digit['T']=29;
83     digit['U']=30;
84     digit['V']=31;
85     digit['W']=32;
86     digit['X']=33;
87     digit['Y']=34;
88     digit['Z']=35;
89 francois 708 }
90    
91    
92    
93    
94     OT_CHAINE::OT_CHAINE(OT_CHAINE& mdd)
95     {
96    
97     }
98    
99    
100    
101     OT_CHAINE::~OT_CHAINE()
102     {
103    
104     }
105    
106    
107    
108     void OT_CHAINE::ini_mg_fprintf(int pos,char c)
109     {
110     longmax=pos;
111     charseparateur=c;
112     }
113    
114    
115     void OT_CHAINE::mg_fprintf(FILE* in,char* message)
116     {
117     std::string chaine=message;
118     int lon=chaine.length();
119     while (lon>longmax)
120     {
121     int pos=chaine.rfind(charseparateur,longmax);
122     std::string chaine1=chaine.substr(0,pos);
123     chaine=chaine.substr(pos);
124     lon=chaine.length();
125     fprintf(in,"%s\n",chaine1.c_str());
126     }
127     fprintf(in,"%s",chaine.c_str());
128    
129    
130     }
131 francois 749
132     std::string OT_CHAINE::get_base(unsigned long val,int base)
133     {
134     std::string res="";
135     do
136     {
137     int reste=val%base;
138     val=val/base;
139     res=transpose[reste]+res;
140     }
141     while (val!=0);
142     return res;
143     }
144 francois 757
145    
146    
147     unsigned long OT_CHAINE::get_base(std::string val,int base)
148     {
149     unsigned long res=0;
150     int taille=val.size();
151     for (int i=taille-1;i>-1;i--)
152     res=res+digit[val[i]]*pow(base,taille-i-1);
153    
154    
155     return res;
156     }
157    
158     long unsigned int OT_CHAINE::atoi(std::string val, int base)
159     {
160     unsigned long res=0;
161     if (base==10) res=atol(val.c_str());
162     else res=get_base(val,base);
163     return res;
164     }
165    
166 francois 711
167     std::vector< std::string> OT_CHAINE::split(std::string chaine, char c)
168     {
169     std::vector<std::string> arg;
170     int pos;
171     do
172     {
173     pos=chaine.find(c);
174     std::string chaine1=chaine.substr(0,pos);
175     arg.push_back(chaine1);
176     if (pos!=std::string::npos)
177     chaine=chaine.substr(pos+1);
178     }
179     while (pos!=std::string::npos);
180     return arg;
181     }
182 francois 775
183    
184     std::string OT_CHAINE::upcase(std::string chaine)
185     {
186     std::locale loc;
187     for (std::string::size_type i=0; i<chaine.length(); ++i)
188     chaine[i]= std::toupper(chaine[i],loc);
189     return chaine;
190    
191     }
192