Commit 0b5d2833 by Maarten L. Hekkelman

replacing std::endl where appropriate

more docs
parent bdbf22e7
......@@ -11,8 +11,8 @@ int main()
std::regex_search(s, m, r);
std::cout << s.substr(0, 10) << std::endl;
std::cout << m.str(1).substr(0, 10) << std::endl;
std::cout << s.substr(0, 10) << '\n';
std::cout << m.str(1).substr(0, 10) << '\n';
return 0;
}
......@@ -27,6 +27,7 @@ The :cpp:class:`cif::file` class encapsulates, you guessed it, the contents of a
:caption: Contents
self
resources.rst
api/library_root.rst
genindex.rst
Resources
=========
Programs using libcifpp often need access to common data files. E.g. CIF dictionary files, CCP4 monomer restraints files or the CCD data file. In libcifpp these files are called resources. These files are often also based on external sources that are updated on a regular basis.
Loading Resources
-----------------
No matter where the resource is located, you should always use the single libcifpp API call :cpp:func:`cif::load_resource` to load them. This function returns a *std::istream* wrapped inside a *std::unique_ptr*.
\ No newline at end of file
......@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
{
if (argc != 2)
{
std::cerr << "Usage: example <inputfile>" << std::endl;
std::cerr << "Usage: example <inputfile>\n";
exit(1);
}
......@@ -17,7 +17,7 @@ int main(int argc, char *argv[])
if (file.empty())
{
std::cerr << "Empty file" << std::endl;
std::cerr << "Empty file\n";
exit(1);
}
......@@ -25,13 +25,13 @@ int main(int argc, char *argv[])
auto &atom_site = db["atom_site"];
auto n = atom_site.find(cif::key("label_atom_id") == "OXT").size();
std::cout << "File contains " << atom_site.size() << " atoms of which " << n << (n == 1 ? " is" : " are") << " OXT" << std::endl
<< "residues with an OXT are:" << std::endl;
std::cout << "File contains " << atom_site.size() << " atoms of which " << n << (n == 1 ? " is" : " are") << " OXT\n"
<< "residues with an OXT are:\n";
for (const auto &[asym, comp, seqnr] : atom_site.find<std::string, std::string, int>(
cif::key("label_atom_id") == "OXT", "label_asym_id", "label_comp_id", "label_seq_id"))
{
std::cout << asym << ' ' << comp << ' ' << seqnr << std::endl;
std::cout << asym << ' ' << comp << ' ' << seqnr << '\n';
}
return 0;
......
......@@ -300,7 +300,7 @@ class category
///
/// @code{.cpp}
/// for (const auto &[name, value] : cat.rows<std::string,int>("item_name", "item_value"))
/// std::cout << name << ": " << value << std::endl;
/// std::cout << name << ": " << value << '\n';
/// @endcode
///
/// @tparam Ts The types for the columns requested
......@@ -318,12 +318,12 @@ class category
///
/// @code{.cpp}
/// for (const auto &[name, value] : cat.rows<std::string,int>("item_name", "item_value"))
/// std::cout << name << ": " << value << std::endl;
/// std::cout << name << ": " << value << '\n';
///
/// // or in case we only need one column:
///
/// for (int id : cat.rows<int>("id"))
/// std::cout << id << std::endl;
/// std::cout << id << '\n';
/// @endcode
///
/// @tparam Ts The types for the columns requested
......@@ -396,7 +396,7 @@ class category
///
/// @code{.cpp}
/// for (const auto &[name, value] : cat.find<std::string,int>(cif::key("item_value") > 10, "item_name", "item_value"))
/// std::cout << name << ": " << value << std::endl;
/// std::cout << name << ": " << value << '\n';
/// @endcode
///
/// @param cond The condition for the query
......@@ -961,7 +961,7 @@ class category
{
auto iv = m_cat_validator->get_validator_for_item(column_name);
if (iv == nullptr)
std::cerr << "Invalid name used '" << column_name << "' is not a known column in " + m_name << std::endl;
std::cerr << "Invalid name used '" << column_name << "' is not a known column in " + m_name << '\n';
}
return result;
......
......@@ -460,9 +460,9 @@ struct item_handle::item_value_as<T, std::enable_if_t<std::is_arithmetic_v<T> an
if (cif::VERBOSE)
{
if (r.ec == std::errc::invalid_argument)
std::cerr << "Attempt to convert " << std::quoted(txt) << " into a number" << std::endl;
std::cerr << "Attempt to convert " << std::quoted(txt) << " into a number\n";
else if (r.ec == std::errc::result_out_of_range)
std::cerr << "Conversion of " << std::quoted(txt) << " into a type that is too small" << std::endl;
std::cerr << "Conversion of " << std::quoted(txt) << " into a type that is too small\n";
}
}
}
......@@ -489,9 +489,9 @@ struct item_handle::item_value_as<T, std::enable_if_t<std::is_arithmetic_v<T> an
if (cif::VERBOSE)
{
if (r.ec == std::errc::invalid_argument)
std::cerr << "Attempt to convert " << std::quoted(txt) << " into a number" << std::endl;
std::cerr << "Attempt to convert " << std::quoted(txt) << " into a number\n";
else if (r.ec == std::errc::result_out_of_range)
std::cerr << "Conversion of " << std::quoted(txt) << " into a type that is too small" << std::endl;
std::cerr << "Conversion of " << std::quoted(txt) << " into a type that is too small\n";
}
result = 1;
}
......
......@@ -236,7 +236,7 @@ class sac_parser
void error(const std::string &msg)
{
if (cif::VERBOSE > 0)
std::cerr << "Error parsing mmCIF: " << msg << std::endl;
std::cerr << "Error parsing mmCIF: " << msg << '\n';
throw parse_error(m_line_nr, msg);
}
......@@ -244,7 +244,7 @@ class sac_parser
void warning(const std::string &msg)
{
if (cif::VERBOSE > 0)
std::cerr << "parser warning at line " << m_line_nr << ": " << msg << std::endl;
std::cerr << "parser warning at line " << m_line_nr << ": " << msg << '\n';
}
// production methods, these are pure virtual here
......
......@@ -196,6 +196,7 @@ inline auto coloured(const char_type *str,
return colour::detail::coloured_string_t<const char_type *>(str, fg, bg, st);
}
/// @brief Manipulator for coloured strings.
template <typename char_type, typename traits_type, typename allocator_type>
inline auto coloured(const std::basic_string<char_type, traits_type, allocator_type> &str,
colour::colour_type fg, colour::colour_type bg = colour::colour_type::none,
......@@ -204,6 +205,7 @@ inline auto coloured(const std::basic_string<char_type, traits_type, allocator_t
return colour::detail::coloured_string_t<const std::basic_string<char_type, traits_type, allocator_type> &>(str, fg, bg, st);
}
/// @brief Manipulator for coloured strings.
template <typename char_type, typename traits_type, typename allocator_type>
inline auto coloured(std::basic_string<char_type, traits_type, allocator_type> &str,
colour::colour_type fg, colour::colour_type bg = colour::colour_type::none,
......@@ -212,6 +214,7 @@ inline auto coloured(std::basic_string<char_type, traits_type, allocator_type> &
return colour::detail::coloured_string_t<std::basic_string<char_type, traits_type, allocator_type> &>(str, fg, bg, st);
}
/// @brief Manipulator for coloured strings.
template <typename char_type, typename traits_type>
inline auto coloured(std::basic_string_view<char_type, traits_type> &str,
colour::colour_type fg, colour::colour_type bg = colour::colour_type::none,
......@@ -327,6 +330,51 @@ class progress_bar
// --------------------------------------------------------------------
// Resources
/**
* @brief Resources are files required to perform some action, e.g.
* dictionary files or the entire CCD file.
*
* Resources can be compiled into the executable so that the resulting
* application can be made portable to other machines. For this you
* need to use https://github.com/mhekkel/mrc.git which only works
* on Un*x like systems using the ELF executable format or on MS Windows
*
* But resources may also be located as files on the filesytem at
* specific locations. And you can specify your own location for
* files (a directory) or even override named resources with your
* own data.
*
* The order in which resources are search for is:
*
* * Use the resource that was defined by calling add_file_resource
* for this name.
*
* * Search the paths specified by add_data_directory, last one
* added is searched first
*
* * Search the so-called CACHE_DIR. This location is defined
* at compile time and based on the installation directory of
* libcifpp. Usually it is /var/cache/libcifpp.
* It is in this directory where the cron job for libcifpp will
* put the updated files weekly.
*
* * If the CCP4 environment is available, the
* $ENV{CCP4}/share/libcifpp is searched.
*
* * If the environment variable LIBCIFPP_DATA_DIR is set it
* is searched
*
* * The DATA_DIR is searched, this is also a variable defined
* at compile time, also based on the installation directory
* of libcifpp. It usually is /usr/share/libcifpp
*
* * As a last resort an attempt is made to load the data from
* resources compiled by mrc.
*
* @param name
* @return std::unique_ptr<std::istream>
*/
std::unique_ptr<std::istream> load_resource(std::filesystem::path name);
void add_file_resource(const std::string &name, std::filesystem::path dataFile);
void add_data_directory(std::filesystem::path dataDir);
......
......@@ -1112,7 +1112,7 @@ auto atom_type_traits::wksf(int charge) const -> const SFData&
// Oops, not found. Fall back to zero charge and see if we can use that
if (cif::VERBOSE > 0)
std::cerr << "No scattering factor found for " << name() << " with charge " << charge << " will try to fall back to zero charge..." << std::endl;
std::cerr << "No scattering factor found for " << name() << " with charge " << charge << " will try to fall back to zero charge...\n";
for (auto& sf: data::kWKSFData)
{
......
......@@ -674,7 +674,7 @@ void category::set_validator(const validator *v, datablock &db)
{
std::ostringstream msg;
msg << "Cannot construct index since the key field" << (missing.size() > 1 ? "s" : "") << " "
<< cif::join(missing, ", ") << " in " << m_name << " " << (missing.size() == 1 ? "is" : "are") << " missing" << std::endl;
<< cif::join(missing, ", ") << " in " << m_name << " " << (missing.size() == 1 ? "is" : "are") << " missing\n";
throw std::runtime_error(msg.str());
}
}
......@@ -723,7 +723,7 @@ bool category::is_valid() const
if (empty())
{
if (VERBOSE > 2)
std::cerr << "Skipping validation of empty category " << m_name << std::endl;
std::cerr << "Skipping validation of empty category " << m_name << '\n';
return true;
}
......@@ -875,17 +875,17 @@ bool category::validate_links() const
{
result = false;
std::cerr << "Links for " << link.v->m_link_group_label << " are incomplete" << std::endl
<< " There are " << missing << " items in " << m_name << " that don't have matching parent items in " << parent->m_name << std::endl;
std::cerr << "Links for " << link.v->m_link_group_label << " are incomplete\n"
<< " There are " << missing << " items in " << m_name << " that don't have matching parent items in " << parent->m_name << '\n';
if (VERBOSE)
{
std::cerr << "showing first " << first_missing_rows.size() << " rows" << std::endl
<< std::endl;
std::cerr << "showing first " << first_missing_rows.size() << " rows\n"
<< '\n';
first_missing_rows.write(std::cerr, link.v->m_child_keys, false);
std::cerr << std::endl;
std::cerr << '\n';
}
}
}
......@@ -1214,9 +1214,9 @@ void category::erase_orphans(condition &&cond, category &parent)
{
category c(m_name);
c.emplace(r);
std::cerr << "Removing orphaned record: " << std::endl
<< c << std::endl
<< std::endl;
std::cerr << "Removing orphaned record: \n"
<< c << '\n'
<< '\n';
}
......@@ -1383,7 +1383,7 @@ void category::update_value(const std::vector<row_handle> &rows, std::string_vie
// cannot update this...
if (cif::VERBOSE > 0)
std::cerr << "Cannot update child " << childCat->m_name << "." << childTag << " with value " << value << std::endl;
std::cerr << "Cannot update child " << childCat->m_name << "." << childTag << " with value " << value << '\n';
}
// finally, update the children
......@@ -1480,8 +1480,8 @@ void category::update_value(row *row, uint16_t column, std::string_view value, b
// if (cif::VERBOSE > 2)
// {
// std::cerr << "Parent: " << linked->mParentcategory << " Child: " << linked->m_child_category << std::endl
// << cond << std::endl;
// std::cerr << "Parent: " << linked->mParentcategory << " Child: " << linked->m_child_category << '\n'
// << cond << '\n';
// }
// Now, suppose there are already rows in child that conform to the new value,
......@@ -1510,7 +1510,7 @@ void category::update_value(row *row, uint16_t column, std::string_view value, b
if (not rows_n.empty())
{
if (cif::VERBOSE > 0)
std::cerr << "Will not rename in child category since there are already rows that link to the parent" << std::endl;
std::cerr << "Will not rename in child category since there are already rows that link to the parent\n";
continue;
}
......@@ -1871,7 +1871,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
if (needLoop)
{
os << "loop_" << '\n';
os << "loop_\n";
std::vector<size_t> columnWidths(m_columns.size());
......@@ -2018,7 +2018,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
}
}
os << "# " << '\n';
os << "# \n";
}
bool category::operator==(const category &rhs) const
......@@ -2031,7 +2031,7 @@ bool category::operator==(const category &rhs) const
// set<std::string> tagsA(a.fields()), tagsB(b.fields());
//
// if (tagsA != tagsB)
// std::cout << "Unequal number of fields" << std::endl;
// std::cout << "Unequal number of fields\n";
const category_validator *catValidator = nullptr;
......
......@@ -209,7 +209,7 @@ compound::compound(cif::datablock &db, const std::string &id, const std::string
else
{
if (cif::VERBOSE > 0)
std::cerr << "Unimplemented chem_comp_bond.type " << btype << " in " << id << std::endl;
std::cerr << "Unimplemented chem_comp_bond.type " << btype << " in " << id << '\n';
bond.type = bond_type::sing;
}
m_bonds.push_back(std::move(bond));
......@@ -466,15 +466,15 @@ compound_factory_impl::compound_factory_impl(const fs::path &file, std::shared_p
if (not cifFile.is_valid())
{
std::cerr << "The components file " << file << " is not valid" << std::endl;
std::cerr << "The components file " << file << " is not valid\n";
if (cif::VERBOSE < 1)
std::cerr << "(use --verbose to see why)" << std::endl;
std::cerr << "(use --verbose to see why)\n";
}
}
catch (const std::exception &e)
{
std::cerr << "When trying to load the components file " << file << " there was an exception:" << std::endl
<< e.what() << std::endl;
std::cerr << "When trying to load the components file " << file << " there was an exception:\n"
<< e.what() << '\n';
}
for (auto &db : cifFile)
......@@ -516,7 +516,7 @@ compound *CCD_compound_factory_impl::create(const std::string &id)
ccd = cif::load_resource("components.cif");
if (not ccd)
{
std::cerr << "Could not locate the CCD components.cif file, please make sure the software is installed properly and/or use the update-libcifpp-data to fetch the data." << std::endl;
std::cerr << "Could not locate the CCD components.cif file, please make sure the software is installed properly and/or use the update-libcifpp-data to fetch the data.\n";
return nullptr;
}
}
......@@ -576,7 +576,7 @@ compound *CCD_compound_factory_impl::create(const std::string &id)
}
if (result == nullptr and cif::VERBOSE > 0)
std::cerr << "Could not locate compound " << id << " in the CCD components file" << std::endl;
std::cerr << "Could not locate compound " << id << " in the CCD components file\n";
return result;
}
......@@ -701,13 +701,13 @@ compound_factory::compound_factory()
if (ccd)
m_impl = std::make_shared<CCD_compound_factory_impl>(m_impl);
else if (cif::VERBOSE > 0)
std::cerr << "CCD components.cif file was not found" << std::endl;
std::cerr << "CCD components.cif file was not found\n";
const char *clibd_mon = getenv("CLIBD_MON");
if (clibd_mon != nullptr and fs::is_directory(clibd_mon))
m_impl = std::make_shared<CCP4_compound_factory_impl>(clibd_mon, m_impl);
else if (cif::VERBOSE > 0)
std::cerr << "CCP4 monomers library not found, CLIBD_MON is not defined" << std::endl;
std::cerr << "CCP4 monomers library not found, CLIBD_MON is not defined\n";
}
compound_factory::~compound_factory()
......
......@@ -198,8 +198,8 @@ std::vector<std::string> datablock::get_tag_order() const
void datablock::write(std::ostream &os) const
{
os << "data_" << m_name << std::endl
<< "# " << std::endl;
os << "data_" << m_name << '\n'
<< "# \n";
// mmcif support, sort of. First write the 'entry' Category
// and if it exists, _AND_ we have a Validator, write out the
......@@ -237,8 +237,8 @@ void datablock::write(std::ostream &os) const
void datablock::write(std::ostream &os, const std::vector<std::string> &tag_order)
{
os << "data_" << m_name << std::endl
<< "# " << std::endl;
os << "data_" << m_name << '\n'
<< "# \n";
std::vector<std::string> cat_order;
for (auto &o : tag_order)
......
......@@ -213,16 +213,16 @@ class dictionary_parser : public parser
ess.insert(e["value"].as<std::string>());
std::string defaultValue = dict["item_default"].front().get<std::string>("value");
bool defaultIsNull = false;
if (defaultValue.empty())
{
// TODO: Is this correct???
for (auto r : dict["_item_default"])
{
defaultIsNull = r["value"].is_null();
break;
}
}
// bool defaultIsNull = false;
// if (defaultValue.empty())
// {
// // TODO: Is this correct???
// for (auto r : dict["_item_default"])
// {
// defaultIsNull = r["value"].is_null();
// break;
// }
// }
// collect the dict from our dataBlock and construct validators
for (auto i : dict["item"])
......@@ -245,7 +245,7 @@ class dictionary_parser : public parser
auto vi = find(ivs.begin(), ivs.end(), item_validator{ item_name });
if (vi == ivs.end())
ivs.push_back(item_validator{ item_name, iequals(mandatory, "yes"), tv, ess, defaultValue, defaultIsNull });
ivs.push_back(item_validator{ item_name, iequals(mandatory, "yes"), tv, ess, defaultValue /*, defaultIsNull*/ });
else
{
// need to update the itemValidator?
......@@ -253,12 +253,12 @@ class dictionary_parser : public parser
{
if (VERBOSE > 2)
{
std::cerr << "inconsistent mandatory value for " << tagName << " in dictionary" << std::endl;
std::cerr << "inconsistent mandatory value for " << tagName << " in dictionary\n";
if (iequals(tagName, saveFrameName))
std::cerr << "choosing " << mandatory << std::endl;
std::cerr << "choosing " << mandatory << '\n';
else
std::cerr << "choosing " << (vi->m_mandatory ? "Y" : "N") << std::endl;
std::cerr << "choosing " << (vi->m_mandatory ? "Y" : "N") << '\n';
}
if (iequals(tagName, saveFrameName))
......@@ -268,7 +268,7 @@ class dictionary_parser : public parser
if (vi->m_type != nullptr and tv != nullptr and vi->m_type != tv)
{
if (VERBOSE > 1)
std::cerr << "inconsistent type for " << tagName << " in dictionary" << std::endl;
std::cerr << "inconsistent type for " << tagName << " in dictionary\n";
}
// vi->mMandatory = (iequals(mandatory, "yes"));
......@@ -410,7 +410,7 @@ class dictionary_parser : public parser
for (auto &iv : cv.m_item_validators)
{
if (iv.m_type == nullptr and cif::VERBOSE >= 0)
std::cerr << "Missing item_type for " << iv.m_tag << std::endl;
std::cerr << "Missing item_type for " << iv.m_tag << '\n';
}
}
}
......@@ -452,7 +452,7 @@ class dictionary_parser : public parser
// mFileImpl.mTypeValidators.erase(v);
if (VERBOSE >= 5)
std::cerr << "Added type " << code << " (" << primitiveCode << ") => " << construct << std::endl;
std::cerr << "Added type " << code << " (" << primitiveCode << ") => " << construct << '\n';
result = true;
}
......
......@@ -58,7 +58,7 @@ bool file::is_valid()
if (m_validator == nullptr)
{
if (VERBOSE > 0)
std::cerr << "No dictionary loaded explicitly, loading default" << std::endl;
std::cerr << "No dictionary loaded explicitly, loading default\n";
load_dictionary();
}
......@@ -108,7 +108,7 @@ void file::load_dictionary()
catch (const std::exception &ex)
{
if (VERBOSE)
std::cerr << "Failed to load dictionary " << std::quoted(name) << ": " << ex.what() << std::endl;
std::cerr << "Failed to load dictionary " << std::quoted(name) << ": " << ex.what() << '\n';
}
}
}
......@@ -219,7 +219,7 @@ void file::save(const std::filesystem::path &p) const
void file::save(std::ostream &os) const
{
// if (not is_valid())
// std::cout << "File is not valid!" << std::endl;
// std::cout << "File is not valid!\n";
for (auto &db : *this)
db.write(os);
......
......@@ -75,7 +75,7 @@ int atom::atom_impl::get_property_int(std::string_view name) const
std::from_chars_result r = std::from_chars(s.data(), s.data() + s.length(), result);
if (r.ec != std::errc() and VERBOSE > 0)
std::cerr << "Error converting " << s << " to number for property " << name << std::endl;
std::cerr << "Error converting " << s << " to number for property " << name << '\n';
}
return result;
}
......@@ -89,7 +89,7 @@ float atom::atom_impl::get_property_float(std::string_view name) const
std::from_chars_result r = cif::from_chars(s.data(), s.data() + s.length(), result);
if (r.ec != std::errc() and VERBOSE > 0)
std::cerr << "Error converting " << s << " to number for property " << name << std::endl;
std::cerr << "Error converting " << s << " to number for property " << name << '\n';
}
return result;
}
......@@ -219,7 +219,7 @@ int atom::atom_impl::get_charge() const
// if (result == nullptr)
// {
// if (VERBOSE > 0)
// std::cerr << "Compound not found: '" << get_property<std::string>("label_comp_id") << '\'' << std::endl;
// std::cerr << "Compound not found: '" << get_property<std::string>("label_comp_id") << '\'' << '\n';
// throw std::runtime_error("no compound");
// }
......@@ -374,7 +374,7 @@ std::vector<atom> residue::unique_atoms() const
else if (alt != firstAlt)
{
if (VERBOSE > 0)
std::cerr << "skipping alternate atom " << atom << std::endl;
std::cerr << "skipping alternate atom " << atom << '\n';
continue;
}
......@@ -412,7 +412,7 @@ atom residue::get_atom_by_atom_id(const std::string &atom_id) const
}
if (not result and VERBOSE > 1)
std::cerr << "atom with atom_id " << atom_id << " not found in residue " << m_asym_id << ':' << m_seq_id << std::endl;
std::cerr << "atom with atom_id " << atom_id << " not found in residue " << m_asym_id << ':' << m_seq_id << '\n';
return result;
}
......@@ -595,7 +595,7 @@ float monomer::alpha() const
catch (const std::exception &ex)
{
if (VERBOSE > 0)
std::cerr << ex.what() << std::endl;
std::cerr << ex.what() << '\n';
}
return result;
......@@ -624,7 +624,7 @@ float monomer::kappa() const
{
if (VERBOSE > 0)
std::cerr << "When trying to calculate kappa for " << m_asym_id << ':' << m_seq_id << ": "
<< ex.what() << std::endl;
<< ex.what() << '\n';
}
return result;
......@@ -647,7 +647,7 @@ float monomer::tco() const
{
if (VERBOSE > 0)
std::cerr << "When trying to calculate tco for " << get_asym_id() << ':' << get_seq_id() << ": "
<< ex.what() << std::endl;
<< ex.what() << '\n';
}
return result;
......@@ -666,7 +666,7 @@ float monomer::omega() const
{
if (VERBOSE > 0)
std::cerr << "When trying to calculate omega for " << get_asym_id() << ':' << get_seq_id() << ": "
<< ex.what() << std::endl;
<< ex.what() << '\n';
}
return result;
......@@ -742,7 +742,7 @@ float monomer::chi(size_t nr) const
catch (const std::exception &e)
{
if (VERBOSE > 0)
std::cerr << e.what() << std::endl;
std::cerr << e.what() << '\n';
result = 0;
}
......@@ -917,7 +917,7 @@ polymer::polymer(structure &s, const std::string &entityID, const std::string &a
else if (VERBOSE > 0)
{
monomer m{*this, index, seqID, authSeqID, pdbInsCode, compoundID};
std::cerr << "Dropping alternate residue " << m << std::endl;
std::cerr << "Dropping alternate residue " << m << '\n';
}
}
}
......@@ -1273,7 +1273,7 @@ structure::structure(datablock &db, size_t modelNr, StructureOpenOptions options
if (model_nr and *model_nr != m_model_nr)
{
if (VERBOSE > 0)
std::cerr << "No atoms loaded for model 1, trying model " << *model_nr << std::endl;
std::cerr << "No atoms loaded for model 1, trying model " << *model_nr << '\n';
m_model_nr = *model_nr;
load_atoms_for_model(options);
}
......@@ -1282,7 +1282,7 @@ structure::structure(datablock &db, size_t modelNr, StructureOpenOptions options
if (m_atoms.empty())
{
if (VERBOSE >= 0)
std::cerr << "Warning: no atoms loaded" << std::endl;
std::cerr << "Warning: no atoms loaded\n";
}
else
load_data();
......@@ -1373,7 +1373,7 @@ void structure::load_data()
if (ri == resMap.end())
{
if (VERBOSE > 0)
std::cerr << "Missing residue for atom " << atom << std::endl;
std::cerr << "Missing residue for atom " << atom << '\n';
// see if it might match a non poly
for (auto &res : m_non_polymers)
......@@ -1815,7 +1815,7 @@ void structure::remove_atom(atom &a, bool removeFromResidue)
catch (const std::exception &ex)
{
if (VERBOSE > 0)
std::cerr << "Error removing atom from residue: " << ex.what() << std::endl;
std::cerr << "Error removing atom from residue: " << ex.what() << '\n';
}
}
......@@ -1996,7 +1996,7 @@ void structure::change_residue(residue &res, const std::string &newCompound,
if (i == atoms.end())
{
if (VERBOSE >= 0)
std::cerr << "Missing atom for atom ID " << a1 << std::endl;
std::cerr << "Missing atom for atom ID " << a1 << '\n';
continue;
}
......@@ -2636,7 +2636,7 @@ std::string structure::create_entity_for_branch(branch &branch)
entityID = entity.get_unique_id("");
if (VERBOSE)
std::cout << "Creating new entity " << entityID << " for branched sugar " << entityName << std::endl;
std::cout << "Creating new entity " << entityID << " for branched sugar " << entityName << '\n';
entity.emplace({
{"id", entityID},
......
......@@ -485,7 +485,7 @@ sac_parser::CIFToken sac_parser::get_next_token()
std::cerr << get_token_name(result);
if (result != CIFToken::Eof)
std::cerr << " " << std::quoted(m_token_value);
std::cerr << std::endl;
std::cerr << '\n';
}
return result;
......@@ -830,7 +830,7 @@ void sac_parser::parse_save_frame()
void parser::produce_datablock(std::string_view name)
{
if (VERBOSE >= 4)
std::cerr << "producing data_" << name << std::endl;
std::cerr << "producing data_" << name << '\n';
const auto &[iter, ignore] = m_file.emplace(name);
m_datablock = &(*iter);
......@@ -839,7 +839,7 @@ void parser::produce_datablock(std::string_view name)
void parser::produce_category(std::string_view name)
{
if (VERBOSE >= 4)
std::cerr << "producing category " << name << std::endl;
std::cerr << "producing category " << name << '\n';
const auto &[cat, ignore] = m_datablock->emplace(name);
m_category = &*cat;
......@@ -848,7 +848,7 @@ void parser::produce_category(std::string_view name)
void parser::produce_row()
{
if (VERBOSE >= 4 and m_category != nullptr)
std::cerr << "producing row for category " << m_category->name() << std::endl;
std::cerr << "producing row for category " << m_category->name() << '\n';
if (m_category == nullptr)
error("inconsistent categories in loop_");
......@@ -861,7 +861,7 @@ void parser::produce_row()
void parser::produce_item(std::string_view category, std::string_view item, std::string_view value)
{
if (VERBOSE >= 4)
std::cerr << "producing _" << category << '.' << item << " -> " << value << std::endl;
std::cerr << "producing _" << category << '.' << item << " -> " << value << '\n';
if (m_category == nullptr or not iequals(category, m_category->name()))
error("inconsistent categories in loop_");
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1043,7 +1043,7 @@ std::string Remark3Parser::nextLine()
}
if (cif::VERBOSE >= 2)
std::cerr << "RM3: " << mLine << std::endl;
std::cerr << "RM3: " << mLine << '\n';
return mLine;
}
......@@ -1060,7 +1060,7 @@ bool Remark3Parser::match(const char *expr, int nextState)
{
using namespace colour;
std::cerr << coloured("No match:", white, red, bold) << " '" << expr << '\'' << std::endl;
std::cerr << coloured("No match:", white, red, bold) << " '" << expr << '\'' << '\n';
}
return result;
......@@ -1124,7 +1124,7 @@ float Remark3Parser::parse()
{
using namespace colour;
std::cerr << coloured("Dropping line:", white, red, bold) << " '" << mLine << '\'' << std::endl;
std::cerr << coloured("Dropping line:", white, red, bold) << " '" << mLine << '\'' << '\n';
}
++dropped;
......@@ -1177,7 +1177,7 @@ void Remark3Parser::storeCapture(const char *category, std::initializer_list<con
continue;
if (cif::VERBOSE >= 3)
std::cerr << "storing: '" << value << "' in _" << category << '.' << item << std::endl;
std::cerr << "storing: '" << value << "' in _" << category << '.' << item << '\n';
auto &cat = mDb[category];
if (cat.empty() or createNew)
......@@ -1338,7 +1338,7 @@ bool Remark3Parser::parse(const std::string &expMethod, PDBRecord *r, cif::datab
if (line != "REFINEMENT.")
{
if (cif::VERBOSE > 0)
std::cerr << "Unexpected data in REMARK 3" << std::endl;
std::cerr << "Unexpected data in REMARK 3\n";
return false;
}
......@@ -1350,7 +1350,7 @@ bool Remark3Parser::parse(const std::string &expMethod, PDBRecord *r, cif::datab
if (not std::regex_match(line, m, rxp))
{
if (cif::VERBOSE > 0)
std::cerr << "Expected valid PROGRAM line in REMARK 3" << std::endl;
std::cerr << "Expected valid PROGRAM line in REMARK 3\n";
return false;
}
......@@ -1389,13 +1389,13 @@ bool Remark3Parser::parse(const std::string &expMethod, PDBRecord *r, cif::datab
catch (const std::exception &e)
{
if (cif::VERBOSE >= 0)
std::cerr << "Error parsing REMARK 3 with " << parser->program() << std::endl
std::cerr << "Error parsing REMARK 3 with " << parser->program() << '\n'
<< e.what() << '\n';
score = 0;
}
if (cif::VERBOSE >= 2)
std::cerr << "Score for " << parser->program() << ": " << score << std::endl;
std::cerr << "Score for " << parser->program() << ": " << score << '\n';
if (score > 0)
{
......@@ -1431,7 +1431,7 @@ bool Remark3Parser::parse(const std::string &expMethod, PDBRecord *r, cif::datab
else if (cif::starts_with(program, "X-PLOR"))
tryParser(new XPLOR_Remark3Parser(program, expMethod, r, db));
else if (cif::VERBOSE > 0)
std::cerr << "Skipping unknown program (" << program << ") in REMARK 3" << std::endl;
std::cerr << "Skipping unknown program (" << program << ") in REMARK 3\n";
}
sort(scores.begin(), scores.end());
......@@ -1440,7 +1440,7 @@ bool Remark3Parser::parse(const std::string &expMethod, PDBRecord *r, cif::datab
if (guessProgram)
{
if (cif::VERBOSE > 0)
std::cerr << "Unknown or untrusted program in REMARK 3, trying all parsers to see if there is a match" << std::endl;
std::cerr << "Unknown or untrusted program in REMARK 3, trying all parsers to see if there is a match\n";
tryParser(new BUSTER_TNT_Remark3Parser("BUSTER-TNT", expMethod, r, db));
tryParser(new CNS_Remark3Parser("CNS", expMethod, r, db));
......@@ -1465,7 +1465,7 @@ bool Remark3Parser::parse(const std::string &expMethod, PDBRecord *r, cif::datab
auto &best = scores.front();
if (cif::VERBOSE > 0)
std::cerr << "Choosing " << best.parser->program() << " version '" << best.parser->version() << "' as refinement program. Score = " << best.score << std::endl;
std::cerr << "Choosing " << best.parser->program() << " version '" << best.parser->version() << "' as refinement program. Score = " << best.score << '\n';
auto &software = db["software"];
std::string program = best.parser->program();
......
......@@ -233,7 +233,7 @@ int main(int argc, char* const argv[])
{
if (argc != 4)
{
std::cerr << "Usage symop-map-generator <syminfo.lib-file> <symop.lib-file> < <output-file>" << std::endl;
std::cerr << "Usage symop-map-generator <syminfo.lib-file> <symop.lib-file> < <output-file>\n";
exit(1);
}
......@@ -420,7 +420,7 @@ const space_group kSpaceGroups[] =
Hall = '"' + Hall + '"' + std::string(40 - Hall.length(), ' ');
out << "\t{ " << old << ", " << xHM << ", " << Hall << ", " << nr << " }," << std::endl;
out << "\t{ " << old << ", " << xHM << ", " << Hall << ", " << nr << " },\n";
}
out << R"(
......@@ -429,7 +429,7 @@ out << R"(
const size_t kNrOfSpaceGroups = sizeof(kSpaceGroups) / sizeof(space_group);
const symop_datablock kSymopNrTable[] = {
)" << std::endl;
)";
int spacegroupNr = 0;
for (auto& sd: data)
......@@ -438,14 +438,14 @@ const symop_datablock kSymopNrTable[] = {
std::tie(sp, o, std::ignore) = sd;
if (sp > spacegroupNr)
out << " // " << symInfo[sp].xHM << std::endl;
out << " // " << symInfo[sp].xHM << '\n';
spacegroupNr = sp;
out << " { " << std::setw(3) << sp
<< ", " << std::setw(3) << o << ", { ";
for (auto& i: std::get<2>(sd))
out << std::setw(2) << i << ',';
out << " } }," << std::endl;
out << " } },\n";
}
out << R"(};
......@@ -453,16 +453,16 @@ const symop_datablock kSymopNrTable[] = {
const size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(symop_datablock);
} // namespace mmcif
)" << std::endl;
)";
out.close();
fs::rename(tmpFile, output);
}
catch (const std::exception& ex)
{
std::cerr << std::endl
<< "Program terminated due to error:" << std::endl
<< ex.what() << std::endl;
std::cerr << '\n'
<< "Program terminated due to error:\n"
<< ex.what() << '\n';
}
return 0;
......
......@@ -364,7 +364,6 @@ const space_group kSpaceGroups[] =
const size_t kNrOfSpaceGroups = sizeof(kSpaceGroups) / sizeof(space_group);
const symop_datablock kSymopNrTable[] = {
// P 1
{ 1, 1, { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, } },
// P -1
......@@ -5290,4 +5289,3 @@ const symop_datablock kSymopNrTable[] = {
const size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(symop_datablock);
} // namespace mmcif
......@@ -242,7 +242,7 @@ void category_validator::addItemValidator(item_validator &&v)
auto r = m_item_validators.insert(std::move(v));
if (not r.second and VERBOSE >= 4)
std::cout << "Could not add validator for item " << v.m_tag << " to category " << m_name << std::endl;
std::cout << "Could not add validator for item " << v.m_tag << " to category " << m_name << '\n';
}
const item_validator *category_validator::get_validator_for_item(std::string_view tag) const
......@@ -252,7 +252,7 @@ const item_validator *category_validator::get_validator_for_item(std::string_vie
if (i != m_item_validators.end())
result = &*i;
else if (VERBOSE > 4)
std::cout << "No validator for tag " << tag << std::endl;
std::cout << "No validator for tag " << tag << '\n';
return result;
}
......@@ -262,7 +262,7 @@ void validator::add_type_validator(type_validator &&v)
{
auto r = m_type_validators.insert(std::move(v));
if (not r.second and VERBOSE > 4)
std::cout << "Could not add validator for type " << v.m_name << std::endl;
std::cout << "Could not add validator for type " << v.m_name << '\n';
}
const type_validator *validator::get_validator_for_type(std::string_view typeCode) const
......@@ -273,7 +273,7 @@ const type_validator *validator::get_validator_for_type(std::string_view typeCod
if (i != m_type_validators.end())
result = &*i;
else if (VERBOSE > 4)
std::cout << "No validator for type " << typeCode << std::endl;
std::cout << "No validator for type " << typeCode << '\n';
return result;
}
......@@ -281,7 +281,7 @@ void validator::add_category_validator(category_validator &&v)
{
auto r = m_category_validators.insert(std::move(v));
if (not r.second and VERBOSE > 4)
std::cout << "Could not add validator for category " << v.m_name << std::endl;
std::cout << "Could not add validator for category " << v.m_name << '\n';
}
const category_validator *validator::get_validator_for_category(std::string_view category) const
......@@ -291,7 +291,7 @@ const category_validator *validator::get_validator_for_category(std::string_view
if (i != m_category_validators.end())
result = &*i;
else if (VERBOSE > 4)
std::cout << "No validator for category " << category << std::endl;
std::cout << "No validator for category " << category << '\n';
return result;
}
......@@ -307,7 +307,7 @@ item_validator *validator::get_validator_for_item(std::string_view tag) const
result = const_cast<item_validator *>(cv->get_validator_for_item(item));
if (result == nullptr and VERBOSE > 4)
std::cout << "No validator for item " << tag << std::endl;
std::cout << "No validator for item " << tag << '\n';
return result;
}
......@@ -376,7 +376,7 @@ void validator::report_error(const std::string &msg, bool fatal) const
if (m_strict or fatal)
throw validation_error(msg);
else if (VERBOSE > 0)
std::cerr << msg << std::endl;
std::cerr << msg << '\n';
}
// --------------------------------------------------------------------
......
......@@ -90,11 +90,11 @@ BOOST_AUTO_TEST_CASE(clr_1)
{
using namespace cif::colour;
std::cout << "Hello, " << cif::coloured("world!", white, red, regular) << std::endl
<< "Hello, " << cif::coloured("world!", white, red, bold) << std::endl
<< "Hello, " << cif::coloured("world!", black, red) << std::endl
<< "Hello, " << cif::coloured("world!", white, green) << std::endl
<< "Hello, " << cif::coloured("world!", white, blue) << std::endl
<< "Hello, " << cif::coloured("world!", blue, white) << std::endl
<< "Hello, " << cif::coloured("world!", red, white, bold) << std::endl;
std::cout << "Hello, " << cif::coloured("world!", white, red, regular) << '\n'
<< "Hello, " << cif::coloured("world!", white, red, bold) << '\n'
<< "Hello, " << cif::coloured("world!", black, red) << '\n'
<< "Hello, " << cif::coloured("world!", white, green) << '\n'
<< "Hello, " << cif::coloured("world!", white, blue) << '\n'
<< "Hello, " << cif::coloured("world!", blue, white) << '\n'
<< "Hello, " << cif::coloured("world!", red, white, bold) << '\n';
}
\ No newline at end of file
......@@ -194,9 +194,9 @@ _atom_type.symbol C
if (not (expected.front() == structure.get_datablock()))
{
BOOST_TEST(false);
std::cout << expected.front() << std::endl
<< std::endl
<< structure.get_datablock() << std::endl;
std::cout << expected.front() << '\n'
<< '\n'
<< structure.get_datablock() << '\n';
}
}
......@@ -306,9 +306,9 @@ _atom_type.symbol C
if (not (expected.front() == structure.get_datablock()))
{
BOOST_TEST(false);
std::cout << expected.front() << std::endl
<< std::endl
<< structure.get_datablock() << std::endl;
std::cout << expected.front() << '\n'
<< '\n'
<< structure.get_datablock() << '\n';
expected.save("/tmp/a");
......
......@@ -72,7 +72,7 @@ int main(int argc, char* argv[])
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
std::cerr << e.what() << '\n';
exit(1);
}
......
......@@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(t1)
BOOST_TEST(rmsd < 1e-5);
// std::cout << "rmsd: " << RMSd(p1, p2) << std::endl;
// std::cout << "rmsd: " << RMSd(p1, p2) << '\n';
}
BOOST_AUTO_TEST_CASE(t2)
......@@ -161,7 +161,7 @@ BOOST_AUTO_TEST_CASE(t3)
v.rotate(q);
v += p[0];
std::cout << v << std::endl;
std::cout << v << '\n';
double a = cif::angle(v, p[0], p[1]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment