Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
86854581
Unverified
Commit
86854581
authored
Jan 11, 2021
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add contructor loading raw data to mmcif::File
parent
ef819448
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
include/cif++/Structure.hpp
+1
-0
src/Structure.cpp
+44
-0
No files found.
include/cif++/Structure.hpp
View file @
86854581
...
...
@@ -390,6 +390,7 @@ class File : public std::enable_shared_from_this<File>
public
:
File
();
File
(
const
std
::
string
&
path
);
File
(
const
char
*
data
,
size_t
length
);
// good luck trying to find out what it is...
~
File
();
File
(
const
File
&
)
=
delete
;
...
...
src/Structure.cpp
View file @
86854581
...
...
@@ -60,10 +60,48 @@ struct FileImpl
cif
::
File
mData
;
cif
::
Datablock
*
mDb
=
nullptr
;
void
load_data
(
const
char
*
data
,
size_t
length
);
void
load
(
const
std
::
string
&
p
);
void
save
(
const
std
::
string
&
p
);
};
void
FileImpl
::
load_data
(
const
char
*
data
,
size_t
length
)
{
try
{
// First try mmCIF
struct
membuf
:
public
std
::
streambuf
{
membuf
(
char
*
data
,
size_t
length
)
{
this
->
setg
(
data
,
data
,
data
+
length
);
}
}
buffer
(
const_cast
<
char
*>
(
data
),
length
);
std
::
istream
is
(
&
buffer
);
mData
.
load
(
is
);
}
catch
(
const
cif
::
CifParserError
&
e
)
{
// First try mmCIF
struct
membuf
:
public
std
::
streambuf
{
membuf
(
char
*
data
,
size_t
length
)
{
this
->
setg
(
data
,
data
,
data
+
length
);
}
}
buffer
(
const_cast
<
char
*>
(
data
),
length
);
std
::
istream
is
(
&
buffer
);
ReadPDBFile
(
is
,
mData
);
}
// Yes, we've parsed the data. Now locate the datablock.
mDb
=
&
mData
.
firstDatablock
();
// And validate, otherwise lots of functionality won't work
// if (mData.getValidator() == nullptr)
mData
.
loadDictionary
(
"mmcif_pdbx_v50"
);
if
(
not
mData
.
isValid
())
std
::
cerr
<<
"Invalid mmCIF file"
<<
(
cif
::
VERBOSE
?
"."
:
" use --verbose option to see errors"
)
<<
std
::
endl
;
}
void
FileImpl
::
load
(
const
std
::
string
&
p
)
{
fs
::
path
path
(
p
);
...
...
@@ -1628,6 +1666,12 @@ File::File()
{
}
File
::
File
(
const
char
*
data
,
size_t
length
)
:
mImpl
(
new
FileImpl
)
{
mImpl
->
load_data
(
data
,
length
);
}
File
::
File
(
const
std
::
string
&
File
)
:
mImpl
(
new
FileImpl
)
{
...
...
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