repr
0.1
Reconstructable string representations and more
Toggle main menu visibility
Main Page
Installation
Usage
Customization
Extending
FAQ
CI Results
Test
Benchmark
API Documentation
Namespace List
Namespace List
Namespace Members
All
_
a
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
Functions
_
a
c
d
e
f
g
i
l
m
n
o
r
s
t
u
v
w
Variables
Typedefs
Enumerations
Concept List
Class List
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Functions
_
a
c
e
f
g
i
l
m
n
o
p
r
s
t
v
w
~
Variables
a
b
c
d
e
f
g
i
k
l
m
n
o
p
q
r
s
t
u
v
Typedefs
a
c
d
e
f
g
h
l
m
p
r
s
t
u
v
w
Enumerations
Enumerator
Related Symbols
File List
File List
File Members
All
_
l
n
o
r
u
Variables
Macros
_
l
o
r
u
Examples
Source Code
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Concepts
Loading...
Searching...
No Matches
layout.h
Go to the documentation of this file.
#pragma once
#include <
librepr/util/string/buffer.h
>
#include <
librepr/reflection/category.h
>
#include <
librepr/name/type.h
>
#include <
librepr/visit.h
>
#include <
type_traits
>
namespace
librepr
{
struct
LayoutVisitor
{
detail::StringBuffer
result
;
private
:
bool
separate =
false
;
void
print_separator() {
if
(separate) {
result
<<
", "
;
}
else
{
separate =
true
;
}
}
template
<
typename
T>
void
print_name() {
if
constexpr
(std::is_pointer_v<T> && std::same_as<std::remove_const_t<std::remove_pointer_t<T>>,
char
>) {
result
<<
"str"
;
}
else
{
result << get_name<T>
();
}
}
template
<category::can_descend T>
void
descend(T
info
) {
separate =
false
;
info
.visit(*
this
);
}
public
:
template
<
typename
T>
void
operator()
(T
info
) {
using
type =
typename
T::type;
print_separator();
if
constexpr
(
requires
{
typename
type::value_type; }) {
// iterable container
result
<<
'['
;
if
constexpr
(
requires
{
typename
type::key_type;
typename
type::mapped_type;
}) {
// associative container
separate =
false
;
librepr::visit<typename type::key_type>
(*
this
);
result
<<
" -> "
;
separate =
false
;
librepr::visit<typename type::mapped_type>
(*
this
);
}
else
{
print_name<typename type::value_type>
();
}
result
<<
']'
;
}
else
{
print_name<type>
();
}
}
void
operator()
(T
info
) {
…
}
template
<category::has_members T>
void
operator()
(T
info
) {
print_separator();
result
<<
'{'
;
descend(
info
);
result
<<
'}'
;
}
void
operator()
(T
info
) {
…
}
template
<category::has_alternatives T>
void
operator()
(T
info
) {
print_separator();
T::alternatives::for_each([
this
, first=
true
]<
typename
U
>()
mutable
{
if
(!first) {
result
<<
" | "
;
}
first =
false
;
separate =
false
;
librepr::visit<U>
(*
this
);
});
}
void
operator()
(T
info
) {
…
}
template
<category::has_enumerator_names T>
void
operator()
(T
info
) {
print_separator();
for
(
auto
const
& name :
info
.enumerator_names) {
if
(&*
info
.enumerator_names.begin() != &name) {
result
<<
" | "
;
}
result
<< name;
}
}
void
operator()
(T
info
) {
…
}
template
<category::has_extent T>
requires
requires
{
typename
T::element_type; }
void
operator()
(T
info
) {
print_name<typename T::element_type>
();
result
<<
'['
<<
std::to_string
(
info
.extent) <<
']'
;
}
void
operator()
(T
info
) {
…
}
};
struct
LayoutVisitor
{
…
};
}
// namespace librepr
include
librepr
visitors
layout.h
Generated by
1.9.8, using the excellent
Doxygen Awesome
Theme