GRINS-0.8.0
physics_naming.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 // This class
26 #include "grins/physics_naming.h"
27 
28 namespace GRINS
29 {
30 
31  void PhysicsNaming::extract_physics_and_suffix( const std::string& full_name,
32  std::string& physics_name,
33  std::string& suffix )
34  {
35  physics_name = PhysicsNaming::extract_physics(full_name);
36  suffix = PhysicsNaming::extract_suffix(full_name);
37  }
38 
39  std::string PhysicsNaming::extract_physics( const std::string& full_name )
40  {
41  // We look for this delimiter to separate the physics name from
42  // the user-supplied suffix
43  std::string delimiter = PhysicsNaming::physics_name_delimiter();
44 
45  std::size_t idx = full_name.find_first_of( delimiter );
46 
47  std::string physics_name;
48 
49  // If this delimiter is not found, then the full_name is the physics_name
50  if( idx == full_name.npos )
51  physics_name = full_name;
52 
53  // If it is found, the first part is the physics_name
54  // and the second part is the suffix
55  else
56  physics_name = full_name.substr(0,idx);
57 
58  return physics_name;
59  }
60 
61  std::string PhysicsNaming::extract_suffix( const std::string& full_name )
62  {
63  // We look for this delimiter to separate the physics name from
64  // the user-supplied suffix
65  std::string delimiter = PhysicsNaming::physics_name_delimiter();
66 
67  std::size_t idx = full_name.find_first_of( delimiter );
68 
69  std::string suffix;
70 
71  // If this delimiter is not found, then there's no suffix
72  // So no need to do anything in that case.
73  // If it is found, the first part is the physics_name
74  // and the second part is the suffix.
75  // Note the suffix extraction *includes* the delimiter
76  if( idx != full_name.npos )
77  suffix = full_name.substr(idx,full_name.npos);
78 
79  return suffix;
80  }
81 
82 } // end namespace GRINS
GRINS namespace.
static std::string extract_physics(const std::string &full_name)
Extract the physics name from the full_name.
static void extract_physics_and_suffix(const std::string &full_name, std::string &physics_name, std::string &suffix)
Extract the physics name and the suffix from the full_name.
static std::string & suffix()
static std::string extract_suffix(const std::string &full_name)
Extract the suffix from the full_name.
static std::string physics_name_delimiter()

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1