Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alvarez, Gonzalo
PsimagLite
Commits
77fff659
Commit
77fff659
authored
Sep 20, 2021
by
Alvarez, Gonzalo
Browse files
Ainur: clean up
parent
f04be18b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Ainur/AinurState.h
View file @
77fff659
...
...
@@ -32,16 +32,9 @@ class AinurState {
{}
template
<
typename
A
,
typename
ContextType
>
typename
EnableIf
<
TypesEqual
<
A
,
T
>::
True
,
void
>::
Type
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
;
template
<
typename
A
,
typename
ContextType
>
typename
EnableIf
<!
TypesEqual
<
A
,
T
>::
True
,
void
>::
Type
operator
()(
A
&
attr
,
ContextType
&
context
,
bool
&
hit
)
const
;
void
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
;
private:
...
...
@@ -57,16 +50,9 @@ class AinurState {
{}
template
<
typename
A
,
typename
ContextType
>
typename
EnableIf
<!
TypesEqual
<
std
::
vector
<
std
::
vector
<
T
>
>
,
A
>::
True
,
void
>::
Type
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
;
template
<
typename
A
,
typename
ContextType
>
typename
EnableIf
<
TypesEqual
<
std
::
vector
<
std
::
vector
<
T
>
>
,
A
>::
True
,
void
>::
Type
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
;
void
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
;
private:
...
...
@@ -88,8 +74,8 @@ public:
AinurState
()
{
assert
(
ZERO_CHAR_STRING_
.
length
()
==
1
);
// if (ZERO_CHAR_STRING_[0] != ' ')
// err("Ainur::AinurState should be a singleton\n");
// if (ZERO_CHAR_STRING_[0] != ' ')
// err("Ainur::AinurState should be a singleton\n");
ZERO_CHAR_STRING_
[
0
]
=
0
;
}
...
...
src/Ainur/AinurState1.cpp
View file @
77fff659
...
...
@@ -96,10 +96,9 @@ void AinurState::assign(String k, String v)
template
<
typename
T
>
template
<
typename
A
,
typename
ContextType
>
typename
EnableIf
<!
TypesEqual
<
std
::
vector
<
std
::
vector
<
T
>
>
,
A
>::
True
,
void
>::
Type
AinurState
::
ActionMatrix
<
T
>::
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
void
AinurState
::
ActionMatrix
<
T
>::
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
{
SizeType
rows
=
attr
.
size
();
if
(
rows
==
0
)
return
;
...
...
@@ -113,53 +112,13 @@ AinurState::ActionMatrix<T>::operator()(A& attr,
}
}
template
<
typename
T
>
template
<
typename
A
,
typename
ContextType
>
typename
EnableIf
<
TypesEqual
<
std
::
vector
<
std
::
vector
<
T
>
>
,
A
>::
True
,
void
>::
Type
AinurState
::
ActionMatrix
<
T
>::
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
{
SizeType
rows
=
attr
.
size
();
if
(
rows
==
0
)
return
;
SizeType
cols
=
attr
[
0
].
size
();
t_
.
resize
(
rows
,
cols
);
for
(
SizeType
i
=
0
;
i
<
rows
;
++
i
)
{
if
(
attr
[
i
].
size
()
!=
cols
)
err
(
"Ainur: Problem reading matrix
\n
"
);
for
(
SizeType
j
=
0
;
j
<
cols
;
++
j
)
t_
(
i
,
j
)
=
attr
[
i
][
j
];
}
}
//---------
template
<
typename
T
>
template
<
typename
A
,
typename
ContextType
>
typename
EnableIf
<
TypesEqual
<
A
,
T
>::
True
,
void
>::
Type
AinurState
::
Action
<
T
>::
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
{
if
(
name_
==
"elipsis"
)
{
SizeType
total
=
t_
.
size
();
if
(
total
==
0
)
err
(
"Elipsis cannot be used for this vector, because size is unknown
\n
"
);
for
(
SizeType
i
=
0
;
i
<
total
;
++
i
)
t_
[
i
]
=
attr
;
return
;
}
t_
.
push_back
(
attr
);
}
template
<
typename
T
>
template
<
typename
A
,
typename
ContextType
>
typename
EnableIf
<!
TypesEqual
<
A
,
T
>::
True
,
void
>::
Type
AinurState
::
Action
<
T
>::
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
void
AinurState
::
Action
<
T
>::
operator
()(
A
&
attr
,
ContextType
&
,
bool
&
)
const
{
const
SizeType
n
=
attr
.
size
();
if
(
n
==
2
&&
attr
[
1
]
==
"..."
)
{
...
...
@@ -240,11 +199,10 @@ void AinurState::convertInternal(std::vector<T>& t,
qi
::
rule
<
IteratorType
,
VectorStringType
(),
qi
::
space_type
>
ruRows
=
ruleRows
();
Action
<
T
>
actionRows
(
"rows"
,
t
);
//Action<T> actionElipsis("elipsis", t);
bool
r
=
qi
::
phrase_parse
(
it
,
value
.
end
(),
ruRows
[
actionRows
],
// | ruElipsis[actionElipsis],
ruRows
[
actionRows
],
qi
::
space
);
//check if we have a match
...
...
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