Kea  1.9.9-git
filename.h
Go to the documentation of this file.
1 // Copyright (C) 2011-2021 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef FILENAME_H
8 #define FILENAME_H
9 
10 #include <string>
11 
12 #include <util/strutil.h>
13 
14 namespace isc {
15 namespace util {
16 
48 
49 
50 class Filename {
51 public:
52 
54  Filename(const std::string& name) :
55  full_name_(""), directory_(""), name_(""), extension_("") {
56  setName(name);
57  }
58 
62  void setName(const std::string& name) {
63  full_name_ = isc::util::str::trim(name);
64 #ifdef WIN32
66 #endif
67  split(full_name_, directory_, name_, extension_);
68  }
69 
71  std::string fullName() const {
72  return (full_name_);
73  }
74 
76  std::string directory() const {
77  return (directory_);
78  }
79 
85  void setDirectory(const std::string& new_directory);
86 
88  std::string name() const {
89  return (name_);
90  }
91 
93  std::string extension() const {
94  return (extension_);
95  }
96 
98  std::string nameAndExtension() const {
99  return (name_ + extension_);
100  }
101 
116  std::string expandWithDefault(const std::string& defname) const;
117 
137  std::string useAsDefault(const std::string& name) const;
138 
139 private:
150  void split(const std::string& full_name, std::string& directory,
151  std::string& name, std::string& extension) const;
152 
153  // Members
154 
155  std::string full_name_;
156  std::string directory_;
157  std::string name_;
158  std::string extension_;
159 };
160 
161 } // namespace util
162 } // namespace isc
163 
164 #endif // FILENAME_H
std::string expandWithDefault(const std::string &defname) const
Expand Name with Default.
Definition: filename.cc:79
void setDirectory(const std::string &new_directory)
Set directory for the file.
Definition: filename.cc:129
std::string fullName() const
Definition: filename.h:71
void setName(const std::string &name)
Sets Stored Filename.
Definition: filename.h:62
std::string extension() const
Definition: filename.h:93
std::string useAsDefault(const std::string &name) const
Use as Default and Substitute into String.
Definition: filename.cc:105
void normalizeSlash(std::string &name)
Normalize Backslash.
Definition: strutil.cc:41
std::string nameAndExtension() const
Definition: filename.h:98
std::string name() const
Definition: filename.h:88
Defines the logger used by the top-level component of kea-dhcp-ddns.
std::string directory() const
Definition: filename.h:76
string trim(const string &instring)
Trim Leading and Trailing Spaces.
Definition: strutil.cc:53
Class to Manipulate Filenames.
Definition: filename.h:50
Filename(const std::string &name)
Constructor.
Definition: filename.h:54