libqasm
library for handling cQASM files
cqasm-utils.cpp
Go to the documentation of this file.
1 
5 #include <algorithm>
6 #include <cctype>
7 #include "cqasm-utils.hpp"
8 
9 namespace cqasm {
10 namespace utils {
11 
15 std::string lowercase(const std::string &name) {
16  std::string name_lower = name;
17  std::for_each(name_lower.begin(), name_lower.end(), [](char &c){
18  c = std::tolower(c);
19  });
20  return name_lower;
21 }
22 
26 bool case_insensitive_equals(const std::string &lhs, const std::string &rhs) {
27  if (lhs.size() != rhs.size()) return false;
28  for (size_t i = 0; i < lhs.size(); i++) {
29  if (std::tolower(lhs[i]) != std::tolower(rhs[i])) return false;
30  }
31  return true;
32 }
33 
34 } // namespace utils
35 } // namespace cqasm
Toplevel namespace with entry points for the new API.
Defines various utility functions.
bool case_insensitive_equals(const std::string &lhs, const std::string &rhs)
Case-insensitive string compare.
Definition: cqasm-utils.cpp:26
std::string lowercase(const std::string &name)
Makes a string lowercase.
Definition: cqasm-utils.cpp:15