commit 3d7d76f578aa48a6b2add2b75b779eebe001723f
Author: Thibaut Cuvelier <[email protected]>
Date: Thu Feb 6 23:35:02 2025 +0100
In MathStream, change MTag and family to use `str::string` instead of C
strings.
`string_view`s would be a great replacement for `const std::string &`, by
the way.
---
src/mathed/InsetMathSymbol.cpp | 5 ++---
src/mathed/MacroTable.cpp | 3 ++-
src/mathed/MathStream.h | 20 ++++++++++----------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp
index e690e2b6d8..ea0ac3f170 100644
--- a/src/mathed/InsetMathSymbol.cpp
+++ b/src/mathed/InsetMathSymbol.cpp
@@ -166,7 +166,7 @@ void InsetMathSymbol::mathmlize(MathMLStream & ms) const
if (sym_->xmlname == "x") {
// unknown so far
ms << name();
- } else if (strcmp(sym_->mathml_type(), "mi") == 0) {
+ } else if (sym_->mathml_type() == "mi") {
// If it's a character or a Greek letter (i.e. "mi"), map to a
font.
ms << StartRespectFont() << sym_->xmlname << StopRespectFont();
} else {
@@ -181,8 +181,7 @@ void InsetMathSymbol::htmlize(HtmlStream & os, bool
spacing) const
{
// FIXME We may need to do more interesting things
// with MathMLtype.
- char const * type = sym_->mathml_type();
- bool op = (std::string(type) == "mo");
+ bool op = sym_->mathml_type() == "mo";
if (sym_->xmlname == "x")
// unknown so far
diff --git a/src/mathed/MacroTable.cpp b/src/mathed/MacroTable.cpp
index 6fa3f1a135..d568c2f326 100644
--- a/src/mathed/MacroTable.cpp
+++ b/src/mathed/MacroTable.cpp
@@ -131,7 +131,8 @@ docstring const MacroData::xmlname() const
char const * MacroData::MathMLtype() const
{
- return sym_ ? sym_->mathml_type() : 0;
+ // TODO: when LyX requires C++17, move to string_view.
+ return sym_ ? sym_->mathml_type().c_str() : 0;
}
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index 4ae9b7e2fc..080f9eaf05 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -410,10 +410,10 @@ private:
class MTag {
public:
///
- MTag(char const * const tag, std::string const & attr = std::string())
+ MTag(const std::string & tag, const std::string & attr = std::string())
: tag_(tag), attr_(attr) {}
///
- char const * const tag_;
+ std::string tag_;
///
std::string attr_;
};
@@ -422,10 +422,10 @@ public:
class MTagInline {
public:
///
- MTagInline(char const * const tag, std::string const & attr =
std::string())
+ MTagInline(const std::string & tag, const std::string & attr =
std::string())
: tag_(tag), attr_(attr) {}
///
- char const * const tag_;
+ std::string tag_;
///
std::string attr_;
};
@@ -435,9 +435,9 @@ public:
class ETag {
public:
///
- explicit ETag(char const * const tag) : tag_(tag) {}
+ explicit ETag(const std::string & tag) : tag_(tag) {}
///
- char const * const tag_;
+ std::string tag_;
};
@@ -445,9 +445,9 @@ public:
class ETagInline {
public:
///
- explicit ETagInline(char const * const tag) : tag_(tag) {}
+ explicit ETagInline(const std::string & tag) : tag_(tag) {}
///
- char const * const tag_;
+ std::string tag_;
};
@@ -455,10 +455,10 @@ public:
class CTag {
public:
///
- CTag(char const * const tag, std::string const & attr = "")
+ CTag(const std::string & tag, std::string const & attr = "")
: tag_(tag), attr_(attr) {}
///
- char const * const tag_;
+ std::string tag_;
///
std::string attr_;
};
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs