Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
ee20bb97
Commit
ee20bb97
authored
1 year ago
by
Bienchen
Browse files
Options
Downloads
Patches
Plain Diff
Allow whitespaces in front of Star-formated lines
parent
eebc74f3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/io/src/mol/star_parser.cc
+31
-16
31 additions, 16 deletions
modules/io/src/mol/star_parser.cc
with
31 additions
and
16 deletions
modules/io/src/mol/star_parser.cc
+
31
−
16
View file @
ee20bb97
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-202
0
by the OpenStructure authors
// Copyright (C) 2008-202
4
by the OpenStructure authors
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
...
...
@@ -257,7 +257,7 @@ void StarParser::ParseLoop()
StarLoopDesc
header
;
this
->
ConsumeLine
();
while
(
this
->
GetLine
(
line
))
{
StringRef
tline
=
line
.
r
trim
();
StringRef
tline
=
line
.
trim
();
if
(
tline
.
empty
())
{
this
->
ConsumeLine
();
continue
;
...
...
@@ -301,22 +301,29 @@ void StarParser::ParseLoop()
this
->
ConsumeLine
();
continue
;
}
switch
(
tline
[
0
])
{
case
'#'
:
this
->
ConsumeLine
();
break
;
case
';'
:
/*
To deal with lines starting with whitespaces, move parsing multi-line
values out of the switch..case construct. Multi-line values starting
with ';' must not have leading whitespace(s).
*/
if
(
tline
[
0
]
==
';'
)
{
if
(
process_rows
)
{
tmp_values
.
push_back
(
String
());
this
->
ParseMultilineValue
(
tmp_values
.
back
());
if
(
tmp_values
.
size
()
==
header
.
GetSize
())
{
this
->
CallOnDataRow
(
header
,
tmp_values
);
tmp_values
.
clear
();
}
}
}
else
{
String
s
;
this
->
ParseMultilineValue
(
s
,
true
);
}
continue
;
}
tline
=
tline
.
ltrim
();
switch
(
tline
[
0
])
{
case
'#'
:
this
->
ConsumeLine
();
break
;
case
'_'
:
return
;
...
...
@@ -342,7 +349,7 @@ void StarParser::ParseLoop()
}
this
->
ConsumeLine
();
break
;
}
}
}
if
(
process_rows
)
{
this
->
OnEndLoop
();
...
...
@@ -476,6 +483,20 @@ void StarParser::ParseData()
this
->
ConsumeLine
();
continue
;
}
/*
To deal with lines starting with whitespaces, move parsing multi-line
values out of the switch..case construct. Multi-line values starting
with ';' must not have leading whitespace(s).
*/
if
(
tline
[
0
]
==
';'
)
{
if
(
skip
)
{
String
s
;
this
->
ParseMultilineValue
(
s
,
true
);
}
continue
;
}
tline
=
tline
.
ltrim
();
switch
(
tline
[
0
])
{
case
'_'
:
if
(
skip
)
{
...
...
@@ -490,12 +511,6 @@ void StarParser::ParseData()
this
->
OnEndData
();
return
;
}
case
';'
:
if
(
skip
)
{
String
s
;
this
->
ParseMultilineValue
(
s
,
true
);
}
break
;
case
'l'
:
if
(
tline
==
StringRef
(
"loop_"
,
5
))
{
this
->
ParseEndDataItemRow
();
...
...
@@ -541,7 +556,7 @@ void StarParser::Parse()
StringRef
line
;
std
::
stringstream
ss
;
while
(
this
->
GetLine
(
line
))
{
StringRef
tline
=
line
.
r
trim
();
StringRef
tline
=
line
.
trim
();
if
(
tline
.
empty
())
{
this
->
ConsumeLine
();
continue
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment