ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/outil/src/ot_chaine.cpp
Revision: 749
Committed: Thu Oct 8 21:35:25 2015 UTC (9 years, 7 months ago) by francois
File size: 1893 byte(s)
Log Message:
parametrage de la numerotation des entites code aster : choix d'une base de description entre 2 et 36 defaut base 10

File Contents

# User Rev Content
1 francois 708 #include "gestionversion.h"
2     #include "ot_chaine.h"
3     #include <string.h>
4     #include <string>
5     #include <iostream>
6     #include <stdio.h>
7    
8    
9    
10    
11    
12     OT_CHAINE::OT_CHAINE()
13     {
14 francois 749 transpose[0]='0';
15     transpose[1]='1';
16     transpose[2]='2';
17     transpose[3]='3';
18     transpose[4]='4';
19     transpose[5]='5';
20     transpose[6]='6';
21     transpose[7]='7';
22     transpose[8]='8';
23     transpose[9]='9';
24     transpose[10]='A';
25     transpose[11]='B';
26     transpose[12]='C';
27     transpose[13]='D';
28     transpose[14]='E';
29     transpose[15]='F';
30     transpose[16]='G';
31     transpose[17]='H';
32     transpose[18]='I';
33     transpose[19]='J';
34     transpose[20]='K';
35     transpose[21]='L';
36     transpose[22]='M';
37     transpose[23]='N';
38     transpose[24]='O';
39     transpose[25]='P';
40     transpose[26]='Q';
41     transpose[27]='R';
42     transpose[28]='S';
43     transpose[29]='T';
44     transpose[30]='U';
45     transpose[31]='V';
46     transpose[32]='W';
47     transpose[33]='X';
48     transpose[34]='Y';
49     transpose[35]='Z';
50    
51 francois 708 }
52    
53    
54    
55    
56     OT_CHAINE::OT_CHAINE(OT_CHAINE& mdd)
57     {
58    
59     }
60    
61    
62    
63     OT_CHAINE::~OT_CHAINE()
64     {
65    
66     }
67    
68    
69    
70     void OT_CHAINE::ini_mg_fprintf(int pos,char c)
71     {
72     longmax=pos;
73     charseparateur=c;
74     }
75    
76    
77     void OT_CHAINE::mg_fprintf(FILE* in,char* message)
78     {
79     std::string chaine=message;
80     int lon=chaine.length();
81     while (lon>longmax)
82     {
83     int pos=chaine.rfind(charseparateur,longmax);
84     std::string chaine1=chaine.substr(0,pos);
85     chaine=chaine.substr(pos);
86     lon=chaine.length();
87     fprintf(in,"%s\n",chaine1.c_str());
88     }
89     fprintf(in,"%s",chaine.c_str());
90    
91    
92     }
93 francois 749
94     std::string OT_CHAINE::get_base(unsigned long val,int base)
95     {
96     std::string res="";
97     do
98     {
99     int reste=val%base;
100     val=val/base;
101     res=transpose[reste]+res;
102     }
103     while (val!=0);
104     return res;
105     }
106 francois 711
107    
108     std::vector< std::string> OT_CHAINE::split(std::string chaine, char c)
109     {
110     std::vector<std::string> arg;
111     int pos;
112     do
113     {
114     pos=chaine.find(c);
115     std::string chaine1=chaine.substr(0,pos);
116     arg.push_back(chaine1);
117     if (pos!=std::string::npos)
118     chaine=chaine.substr(pos+1);
119     }
120     while (pos!=std::string::npos);
121     return arg;
122     }