Apache Mesos
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
3rdparty
stout
include
stout
uri.hpp
Go to the documentation of this file.
1
// Licensed under the Apache License, Version 2.0 (the "License");
2
// you may not use this file except in compliance with the License.
3
// You may obtain a copy of the License at
4
//
5
// http://www.apache.org/licenses/LICENSE-2.0
6
//
7
// Unless required by applicable law or agreed to in writing, software
8
// distributed under the License is distributed on an "AS IS" BASIS,
9
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
// See the License for the specific language governing permissions and
11
// limitations under the License.
12
13
#ifndef __STOUT_URI_HPP__
14
#define __STOUT_URI_HPP__
15
16
#include <string>
17
18
#include <
stout/strings.hpp
>
19
20
21
namespace
uri
{
22
23
const
std::string
FILE_PREFIX
=
"file://"
;
24
25
26
// Returns a valid URI containing a filename.
27
//
28
// On Windows, the / character is replaced with \ since that's the path
29
// separator. Note that / will often work, but will absolutely not work if the
30
// path is a long path.
31
inline
std::string
from_path
(
const
std::string& filepath)
32
{
33
#ifdef __WINDOWS__
34
return
FILE_PREFIX +
strings::replace
(filepath,
"\\"
,
"/"
);
35
#else
36
return
FILE_PREFIX + filepath;
37
#endif // __WINDOWS__
38
}
39
40
}
// namespace uri {
41
42
#endif // __STOUT_URI_HPP__
uri::from_path
std::string from_path(const std::string &filepath)
Definition:
uri.hpp:31
uri::FILE_PREFIX
const std::string FILE_PREFIX
Definition:
uri.hpp:23
strings::replace
std::string replace(const std::string &s, const std::string &from, const std::string &to)
Definition:
strings.hpp:113
uri
Definition:
uri.hpp:21
strings.hpp
Generated by
1.8.11