ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/CAD4FE/src/CAD4FE_HtmlText.cpp
Revision: 1158
Committed: Thu Jun 13 22:18:49 2024 UTC (11 months ago) by francois
File size: 3051 byte(s)
Log Message:
compatibilité Ubuntu 22.04
Suppression des refeences à Windows
Ajout d'une banière

File Contents

# User Rev Content
1 francois 1158 //####//------------------------------------------------------------
2     //####//------------------------------------------------------------
3     //####// MAGiC
4     //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5     //####// Departement de Genie Mecanique - UQTR
6     //####//------------------------------------------------------------
7     //####// MAGIC est un projet de recherche de l equipe ERICCA
8     //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9     //####// http://www.uqtr.ca/ericca
10     //####// http://www.uqtr.ca/
11     //####//------------------------------------------------------------
12     //####//------------------------------------------------------------
13     //####//
14     //####// CAD4FE_HtmlText.cpp
15     //####//
16     //####//------------------------------------------------------------
17     //####//------------------------------------------------------------
18     //####// COPYRIGHT 2000-2024
19     //####// jeu 13 jun 2024 11:58:56 EDT
20     //####//------------------------------------------------------------
21     //####//------------------------------------------------------------
22 foucault 176 #include "gestionversion.h"
23 foucault 27
24 foucault 176 #include "CAD4FE_Common_platform.h"
25    
26     #include <stdlib.h>
27 foucault 27 #include <sstream>
28     #include <fstream>
29     #include <map>
30     #include <vector>
31     #include <set>
32 francois 1158
33 foucault 176 #include <unistd.h>
34 foucault 27
35    
36    
37 francois 1158
38 foucault 27 #include "CAD4FE_HtmlText.h"
39    
40 francois 1158
41 foucault 27 using namespace CAD4FE;
42    
43     HtmlText_Table::HtmlText_Table (std::vector <std::string> & __head)
44     {
45     _head = __head;
46     }
47    
48     HtmlText_Table::HtmlText_Table (std::vector <std::string> & __head, std::vector < std::vector <std::string> > & __rows)
49     {
50     _head = __head;
51     _rows = __rows;
52     }
53    
54     void HtmlText_Table::AddRow (std::vector <std::string> & __row)
55     {
56     _rows.push_back(__row);
57     }
58    
59     std::string HtmlText_Table::GetHtml()
60     {
61     std::ostringstream out;
62     out << "<table border=\"2\" cellpadding=5 frame=\"vhsides\" rules=\"cols\">\n";
63     out << "<tr>";
64     for (unsigned i=0; i<_head.size(); i++)
65     out << "<th>" << _head[i] << "</th>";
66     out << "</tr>\n";
67     for (unsigned j=0; j<_rows.size(); j++)
68     {
69     std::vector <std::string> & row = _rows[j];
70     out << "<tr>";
71     for (unsigned i=0; i<row.size(); i++)
72     out << "<td>" << row[i] << "</td>";
73     out << "</tr>\n";
74     }
75     out << "</table>\n";
76     return out.str();
77     }
78    
79     HtmlText_Page::HtmlText_Page()
80     {
81     }
82    
83     void HtmlText_Page::Add(std::string __html)
84     {
85     _html += __html;
86     }
87    
88     void HtmlText_Page::operator << (const std::ostringstream & __os)
89     {
90     _html += __os.str();
91     }
92    
93     void HtmlText_Page::Close()
94     {
95     }
96    
97     std::string HtmlText_Page::GetHtml()
98     {
99     return _html;
100     }
101    
102    
103     void HtmlText_Page::Show(std::string __filename)
104     {
105     WriteFile(__filename);
106 francois 1158
107 foucault 176 char htmlViewer[] = "firefox";
108     execl(htmlViewer, __filename.c_str());
109    
110 francois 1158
111 foucault 27 }
112    
113     void HtmlText_Page::WriteFile(std::string __filename)
114     {
115     std::ofstream file;
116     file.open(__filename.c_str());
117     file << _html;
118     file.close();
119     }
120    
121    
122     void HtmlText_Page::Clear()
123     {
124     _html.clear();
125     }
126