LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
ReplaceEscapes.hpp
Go to the documentation of this file.
1 // Copyright (c) 2014-2019, Lawrence Livermore National Security, LLC.
3 // Produced at the Lawrence Livermore National Laboratory.
4 // Written by the LBANN Research Team (B. Van Essen, et al.) listed in
5 // the CONTRIBUTORS file. <lbann-dev@llnl.gov>
6 //
7 // LLNL-CODE-697807.
8 // All rights reserved.
9 //
10 // This file is part of LBANN: Livermore Big Artificial Neural Network
11 // Toolkit. For details, see http://software.llnl.gov/LBANN or
12 // https://github.com/LLNL/LBANN.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "Licensee"); you
15 // may not use this file except in compliance with the License. You may
16 // obtain a copy of the License at:
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
23 // implied. See the License for the specific language governing
24 // permissions and limitations under the license.
26 
27 #ifndef LBANN_UNIT_TEST_UTILITIES_REPLACE_ESCAPES_HPP_INCLUDED
28 #define LBANN_UNIT_TEST_UTILITIES_REPLACE_ESCAPES_HPP_INCLUDED
29 
31 
32 #include <stdexcept>
33 #include <string>
34 
35 namespace unit_test
36 {
37 namespace utilities
38 {
39 
40 //
41 // NOTE TO C++ READERS: The following documentation will appear WRONG
42 // to you, but it is not! DO NOT CHANGE THE PATTERN/REPLACEMENT TABLE!
43 // There are many extra percent signs, but these are necessary for the
44 // markdown to render the HTML correctly! For your benefit, the valid
45 // sequences are:
46 //
47 // %% -- A literal percent sign
48 // %h -- The hostname of the current process
49 // %p -- The PID of the current process
50 // %r -- the MPI rank of the current process, if available, or 0
51 // %s -- the MPI size of the current job, if available, or 1
52 // %env{NAME} -- The value of ${NAME} in the current environment
53 //
54 
91 std::string replace_escapes(
92  std::string const& str, lbann::utils::SystemInfo const& sys_info);
93 
95 struct BadSubstitutionPattern : std::runtime_error
96 {
97  BadSubstitutionPattern(std::string const& str);
98 };// struct BadSubstitutionPattern
99 
100 }// namespace utilities
101 }// namespace unit_test
102 #endif // LBANN_UNIT_TEST_UTILITIES_REPLACE_ESCAPES_HPP_INCLUDED
Query basic system information.
Definition: system_info.hpp:42
BadSubstitutionPattern(std::string const &str)
Indicates that an invalid pattern is detected.
std::string replace_escapes(std::string const &str, lbann::utils::SystemInfo const &sys_info)
Substitute basic escape sequences in a string.