Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
Takin
mag-core
Commits
17e2dacc
Commit
17e2dacc
authored
Jul 17, 2018
by
Tobias WEBER
Browse files
continued with unserialisation
parent
70354074
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/cli/sym.cpp
View file @
17e2dacc
...
...
@@ -9,6 +9,7 @@
#include
"tools/in20/globals.h"
#include
"funcs.h"
#include
"tlibs/string/string.h"
#include
<cmath>
...
...
@@ -405,7 +406,7 @@ std::string SymbolList::serialise() const
std
::
string
SymbolDataset
::
serialise
()
const
{
std
::
ostringstream
ostr
;
ostr
.
precision
(
8
);
ostr
.
precision
(
std
::
numeric_limits
<
t_real
>::
digits10
);
return
ostr
.
str
();
}
...
...
@@ -416,5 +417,33 @@ std::string SymbolDataset::serialise() const
*/
std
::
shared_ptr
<
Symbol
>
Symbol
::
unserialise
(
const
std
::
string
&
str
)
{
auto
[
ty
,
val
]
=
tl
::
split_first
(
str
,
std
::
string
(
":"
));
tl
::
trim
(
ty
);
if
(
ty
==
"real"
)
{
t_real
d
=
tl
::
str_to_var
<
t_real
>
(
val
);
return
std
::
make_shared
<
SymbolReal
>
(
d
);
}
else
if
(
ty
==
"string"
)
{
return
std
::
make_shared
<
SymbolString
>
(
val
);
}
else
if
(
ty
==
"list"
||
ty
==
"array"
)
{
std
::
vector
<
std
::
shared_ptr
<
Symbol
>>
vec
;
// TODO
return
std
::
make_shared
<
SymbolList
>
(
vec
,
ty
==
"list"
);
}
else
if
(
ty
==
"dataset"
)
{
Dataset
dataset
;
// TODO
return
std
::
make_shared
<
SymbolDataset
>
(
dataset
);
}
print_err
(
"Unknown variable type: "
,
ty
,
"."
);
return
nullptr
;
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment