Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CTA-LAPP
PHOENIX_LIBS
PhoenixHDF5
Commits
4ae8277c
Commit
4ae8277c
authored
Nov 24, 2020
by
Pierre Aubert
Browse files
Add resize, clear and alocate
parent
bcc079e6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
4 deletions
+90
-4
src/BackEnd/backend.cpp
src/BackEnd/backend.cpp
+65
-2
src/FrontEnd/ConfigParser.cpp
src/FrontEnd/ConfigParser.cpp
+21
-2
src/FrontEnd/ConfigParser.h
src/FrontEnd/ConfigParser.h
+4
-0
No files found.
src/BackEnd/backend.cpp
View file @
4ae8277c
...
...
@@ -80,11 +80,11 @@ std::string ph5_backendTableHeader(const PTable & table){
body
+=
ph5_backendTableHeaderCompType
(
table
);
body
+=
"
\t
private:
\n
"
;
body
+=
"
\t\t
void allocate(size_t nbRow);
\n
"
;
body
+=
"
\t\t
///Number of rows in the table "
+
name
+
"
\n
"
;
body
+=
"
\t\t
size_t p_nbRow;
\n
"
;
body
+=
ph5_backendTableHeaderAttribute
(
table
);
body
+=
"};
\n\n
"
;
return
body
;
}
...
...
@@ -108,6 +108,60 @@ std::string ph5_backendHeader(const PSource & source){
return
body
;
}
///Save the source of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableSourceResize
(
const
PTable
&
table
){
std
::
string
body
(
""
),
name
(
table
.
getName
());
body
+=
"///Resize the table "
+
name
+
"
\n
"
;
body
+=
"/*
\t
@param nbRow : new number of rows of the Table
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"void "
+
name
+
"::resize(size_t nbRow){
\n
"
;
body
+=
"
\t
if(nbRow == p_nbRow){return;} //Nothing to do
\n
"
;
body
+=
"
\t
clear()
\n
"
;
body
+=
"
\t
allocate(nbRow);
\n
"
;
body
+=
"}
\n\n
"
;
return
body
;
}
///Save the source of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableSourceClear
(
const
PTable
&
table
){
std
::
string
body
(
""
),
name
(
table
.
getName
());
body
+=
"///Clear the table "
+
name
+
" (delete all column)
\n
"
;
body
+=
"void "
+
name
+
"::clear(){
\n
"
;
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
body
+=
"
\t
if(p_"
+
it
->
getName
()
+
" != NULL){delete [] p_"
+
it
->
getName
()
+
";p_"
+
it
->
getName
()
+
" = NULL;}
\n
"
;
}
body
+=
"}
\n\n
"
;
return
body
;
}
///Save the source of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableSourceAllocate
(
const
PTable
&
table
){
std
::
string
body
(
""
),
name
(
table
.
getName
());
body
+=
"///Allocate the table "
+
name
+
" (delete all column)
\n
"
;
body
+=
"/*
\t
@param nbRow : new number of rows of the Table
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"void "
+
name
+
"::allocate(size_t nbRow){
\n
"
;
body
+=
"
\t
p_nbRow = nbRow;
\n
"
;
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
body
+=
"
\t
p_"
+
it
->
getName
()
+
" = new "
+
it
->
getType
()
+
"[p_nbRow];}
\n
"
;
}
body
+=
"}
\n\n
"
;
return
body
;
}
///Save the source of the given PTable
/** @param table : PTable to be used
* @return corresponding string
...
...
@@ -117,12 +171,21 @@ std::string ph5_backendTableSource(const PTable & table){
body
+=
"///Constructor of the class "
+
name
+
"
\n
"
;
body
+=
name
+
"::"
+
name
+
"(){
\n
"
;
body
+=
"
\t
p_nbRow = 0lu;
\n
"
;
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
body
+=
"
\t
p_"
+
it
->
getName
()
+
" = NULL;
\n
"
;
}
body
+=
"}
\n\n
"
;
body
+=
"///Destructor of the class "
+
name
+
"
\n
"
;
body
+=
name
+
"::~"
+
name
+
"(){
\n
"
;
body
+=
"
\t\n
"
;
body
+=
"
\t
clear();
\n
"
;
body
+=
"}
\n\n
"
;
body
+=
ph5_backendTableSourceResize
(
table
);
body
+=
ph5_backendTableSourceClear
(
table
);
body
+=
ph5_backendTableSourceAllocate
(
table
);
return
body
;
}
...
...
src/FrontEnd/ConfigParser.cpp
View file @
4ae8277c
...
...
@@ -52,12 +52,15 @@ void ConfigParser::copyConfigParser(const ConfigParser & other){
*/
bool
ConfigParser
::
parseFile
(){
if
(
!
p_run
)
return
false
;
p_lastDocString
=
""
;
PSource
source
;
source
.
setName
(
getFileName
(
p_parser
->
getFileName
()));
//To parse the file we need to read char by char until we get something we know
while
(
!
p_parser
->
isEndOfFile
()
&&
p_run
){
//If we are not at the end of the file
PTable
table
;
if
(
parseTable
(
table
)){
if
(
parseDocString
()){}
else
if
(
p_parser
->
isMatch
(
"//"
)){
p_parser
->
getUntilKeyWithoutPatern
(
"
\n
"
);}
//Skip comment
else
if
(
parseTable
(
table
)){
source
.
getVecTable
().
push_back
(
table
);
}
else
{
errorAt
();
...
...
@@ -85,6 +88,16 @@ void ConfigParser::initialisationConfigParser(){
}
///Parse a doc string
/** @return true on success, false otherwise
*/
bool
ConfigParser
::
parseDocString
(){
if
(
!
p_parser
->
isMatch
(
"///"
)){
return
false
;}
p_lastDocString
=
p_parser
->
getUntilKeyWithoutPatern
(
"
\n
"
);
return
true
;
}
///Parse a PTable
/** @param[out] table : PTable to be parsed
* @return true on success, false otherwise
...
...
@@ -92,6 +105,8 @@ void ConfigParser::initialisationConfigParser(){
bool
ConfigParser
::
parseTable
(
PTable
&
table
){
std
::
string
tableName
(
p_parser
->
getNextToken
());
std
::
string
dataSetName
(
tableName
);
table
.
setDocString
(
p_lastDocString
);
p_lastDocString
=
""
;
if
(
p_parser
->
isMatch
(
"["
)){
dataSetName
=
p_parser
->
getUntilKeyWithoutPatern
(
"]"
);
}
...
...
@@ -105,7 +120,9 @@ bool ConfigParser::parseTable(PTable & table){
while
(
!
p_parser
->
isEndOfFile
()
&&
!
p_parser
->
isMatch
(
"}"
)
&&
p_run
){
PAttribute
attr
;
if
(
parseAttribute
(
attr
)){
if
(
parseDocString
()){}
else
if
(
p_parser
->
isMatch
(
"//"
)){
p_parser
->
getUntilKeyWithoutPatern
(
"
\n
"
);}
//Skip comment
else
if
(
parseAttribute
(
attr
)){
table
.
getVecAttribute
().
push_back
(
attr
);
}
else
{
errorAt
();
...
...
@@ -123,6 +140,8 @@ bool ConfigParser::parseTable(PTable & table){
*/
bool
ConfigParser
::
parseAttribute
(
PAttribute
&
attr
){
if
(
p_parser
->
isMatchRewind
(
"}"
)){
return
true
;}
attr
.
setDocString
(
p_lastDocString
);
p_lastDocString
=
""
;
std
::
string
type
(
""
);
if
(
p_parser
->
isMatch
(
"Tensor"
)){
if
(
!
p_parser
->
isMatch
(
"("
)){
...
...
src/FrontEnd/ConfigParser.h
View file @
4ae8277c
...
...
@@ -30,10 +30,14 @@ class ConfigParser : public PMultiFileParser{
private:
void
initialisationConfigParser
();
bool
parseDocString
();
bool
parseTable
(
PTable
&
table
);
bool
parseAttribute
(
PAttribute
&
attr
);
bool
parseDimention
(
PDimention
&
dim
);
///Last documentation string
std
::
string
p_lastDocString
;
///Vector of parsed PSource
PVecSource
p_vecSource
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment