X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fsymbol.cpp;h=4dd0691c648ac435b4ef60cbaf1074f6fed28ff5;hp=c9db110fdc43a1cfb581128d48f592553644cfae;hb=1b8bcb068171ce9d5c8202ae3c76647b65c9a06d;hpb=c40c54f17b68f79ee42833adb3364970385e2caa diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index c9db110f..4dd0691c 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's symbolic objects. */ /* - * GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2015 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -106,9 +106,9 @@ void symbol::read_archive(const archive_node &n, lst &sym_lst) n.find_string("name", tmp_name); // If symbol is in sym_lst, return the existing symbol - for (lst::const_iterator it = sym_lst.begin(); it != sym_lst.end(); ++it) { - if (is_a(*it) && (ex_to(*it).name == tmp_name)) { - *this = ex_to(*it); + for (auto & s : sym_lst) { + if (is_a(s) && (ex_to(s).name == tmp_name)) { + *this = ex_to(s); // XXX: This method is responsible for reading realsymbol // and possymbol objects too. But // basic::operator=(const basic& other) @@ -150,12 +150,21 @@ static const std::string& get_default_TeX_name(const std::string& name); // public +std::string symbol::get_name() const +{ + if (name.empty()) { + std::ostringstream s; + s << "symbol" << serial; + name = s.str(); + } + return name; +} + +// protected + void symbol::do_print(const print_context & c, unsigned level) const { - if (!name.empty()) - c.s << name; - else - c.s << "symbol" << serial; + c.s << get_name(); } void symbol::do_print_latex(const print_latex & c, unsigned level) const