Kea 1.5.0
filename.h
Go to the documentation of this file.
1// Copyright (C) 2011-2015 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
14namespace isc {
15namespace util {
16
48
49
50class Filename {
51public:
52
54 Filename(const std::string& name) :
55 full_name_(""), directory_(""), name_(""), extension_("")
56 {
58 }
59
63 void setName(const std::string& name) {
64 full_name_ = isc::util::str::trim(name);
65#ifdef WIN32
67#endif
68 split(full_name_, directory_, name_, extension_);
69 }
70
72 std::string fullName() const {
73 return (full_name_);
74 }
75
77 std::string directory() const {
78 return (directory_);
79 }
80
86 void setDirectory(const std::string& new_directory);
87
89 std::string name() const {
90 return (name_);
91 }
92
94 std::string extension() const {
95 return (extension_);
96 }
97
99 std::string nameAndExtension() const {
100 return (name_ + extension_);
101 }
102
117 std::string expandWithDefault(const std::string& defname) const;
118
138 std::string useAsDefault(const std::string& name) const;
139
140private:
151 void split(const std::string& full_name, std::string& directory,
152 std::string& name, std::string& extension) const;
153
154 // Members
155
156 std::string full_name_;
157 std::string directory_;
158 std::string name_;
159 std::string extension_;
160};
161
162} // namespace util
163} // namespace isc
164
165#endif // FILENAME_H
Class to Manipulate Filenames.
Definition: filename.h:50
std::string extension() const
Definition: filename.h:94
Filename(const std::string &name)
Constructor.
Definition: filename.h:54
std::string name() const
Definition: filename.h:89
void setName(const std::string &name)
Sets Stored Filename.
Definition: filename.h:63
std::string nameAndExtension() const
Definition: filename.h:99
std::string expandWithDefault(const std::string &defname) const
Expand Name with Default.
Definition: filename.cc:80
std::string fullName() const
Definition: filename.h:72
std::string directory() const
Definition: filename.h:77
void setDirectory(const std::string &new_directory)
Set directory for the file.
Definition: filename.cc:130
std::string useAsDefault(const std::string &name) const
Use as Default and Substitute into String.
Definition: filename.cc:106
void normalizeSlash(std::string &name)
Normalize Backslash.
Definition: strutil.cc:41
string trim(const string &instring)
Trim Leading and Trailing Spaces.
Definition: strutil.cc:53
Defines the logger used by the top-level component of kea-dhcp-ddns.