Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
print_dialect.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//print_dialect.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//print_dialect.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with print_dialect.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
46
47#pragma once
48
49#include <ios>
50
51namespace bertini {
52namespace node {
53
55enum class PrintDialect
56{
57 Classic = 0,
60};
61
63inline int PrintDialectSlot()
64{
65 static int const slot = std::ios_base::xalloc();
66 return slot;
67}
68
70inline PrintDialect DialectOf(std::ios_base& stream)
71{
72 return static_cast<PrintDialect>(stream.iword(PrintDialectSlot()));
73}
74
76inline void SetDialect(std::ios_base& stream, PrintDialect dialect)
77{
78 stream.iword(PrintDialectSlot()) = static_cast<long>(dialect);
79}
80
82inline char const* PowerSymbol(PrintDialect dialect)
83{
84 return dialect == PrintDialect::Classic ? "^" : "**";
85}
86
87} // namespace node
88} // namespace bertini
Definition canonical.hpp:56
int PrintDialectSlot()
The stream-state slot the dialect is kept in (allocated once per process).
Definition print_dialect.hpp:63
PrintDialect
Who a printed expression is for; selects the operator and constant spellings.
Definition print_dialect.hpp:56
@ PythonReadable
Python str: **, the same constant shapes, readable first.
Definition print_dialect.hpp:58
@ PythonExact
Python repr: **, exact constant spellings that eval rebuilds at full precision.
Definition print_dialect.hpp:59
@ Classic
Bertini 1 input: ^, (re+im*I), all digits.
Definition print_dialect.hpp:57
char const * PowerSymbol(PrintDialect dialect)
The power operator in a dialect: ^ for Bertini 1, ** for Python.
Definition print_dialect.hpp:82
PrintDialect DialectOf(std::ios_base &stream)
The dialect a stream prints in; Classic unless SetDialect was called on it.
Definition print_dialect.hpp:70
void SetDialect(std::ios_base &stream, PrintDialect dialect)
Choose the dialect everything subsequently printed to stream is written in.
Definition print_dialect.hpp:76
Definition algorithm_builder.hpp:36