Vcsn  2.3a
Be Rational
escape.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iosfwd>
4 #include <iostream>
5 #include <sstream>
6 #include <string>
7 #include <vector>
8 
9 #include <vcsn/misc/export.hh>
10 
11 namespace vcsn LIBVCSN_API
12 {
14  std::ostream& str_escape(std::ostream& os, const std::string& str,
15  const char* special = nullptr);
16 
18  template <typename T>
19  std::ostream& str_escape(std::ostream& os,
20  const std::vector<T>& s,
21  const char* special = nullptr)
22  {
23  for (auto c: s)
24  str_escape(os, c, special);
25  return os;
26  }
27 
30  std::ostream& str_escape(std::ostream& os, int c,
31  const char* special = nullptr);
32 
34  std::ostream& str_escape(std::ostream& os, char c,
35  const char* special = nullptr);
36 
37  template <typename T>
38  std::string str_escape(T&& s,
39  const char* special = nullptr)
40  {
41  std::ostringstream o;
42  str_escape(o, std::forward<T>(s), special);
43  return o.str();
44  }
45 }
Definition: a-star.hh:8
std::ostringstream os
The output stream: the corresponding C++ snippet to compile.
Definition: translate.cc:375
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.
Definition: escape.cc:51
#define LIBVCSN_API
Definition: export.hh:8