diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-13 13:46:20 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-13 13:46:20 +0000 |
| commit | 62ee85a258aa9329544d8542dfbcc40ce8177a7a (patch) | |
| tree | 8579cd323c127bb3bff23c216a55cc92a7001651 /src | |
| parent | ceb30c0b2e73588daa014af57deee7255b175e4d (diff) | |
Use boost starts/ends with methods.
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset_map.cc | 3 | ||||
| -rw-r--r-- | src/dcp.cc | 3 | ||||
| -rw-r--r-- | src/util.cc | 28 | ||||
| -rw-r--r-- | src/util.h | 2 |
4 files changed, 4 insertions, 32 deletions
diff --git a/src/asset_map.cc b/src/asset_map.cc index 4fda0a89..8fcc515f 100644 --- a/src/asset_map.cc +++ b/src/asset_map.cc @@ -21,6 +21,7 @@ * @brief Classes used to parse a AssetMap. */ +#include <boost/algorithm/string.hpp> #include "asset_map.h" #include "util.h" @@ -55,7 +56,7 @@ Chunk::Chunk (xmlpp::Node const * node) string const prefix = "file://"; - if (starts_with (path, prefix)) { + if (boost::algorithm::starts_with (path, prefix)) { path = path.substr (prefix.length()); } @@ -27,6 +27,7 @@ #include <cassert> #include <iostream> #include <boost/filesystem.hpp> +#include <boost/algorithm/string.hpp> #include <libxml++/libxml++.h> #include "dcp.h" #include "asset.h" @@ -197,7 +198,7 @@ DCP::read (bool require_mxfs) boost::filesystem::path t = _directory; t /= (*i)->chunks.front()->path; - if (ends_with (t.string(), ".mxf") || ends_with (t.string(), ".ttf")) { + if (boost::algorithm::ends_with (t.string(), ".mxf") || boost::algorithm::ends_with (t.string(), ".ttf")) { continue; } diff --git a/src/util.cc b/src/util.cc index ca621a44..6769cc41 100644 --- a/src/util.cc +++ b/src/util.cc @@ -165,34 +165,6 @@ libdcp::content_kind_from_string (string type) assert (false); } -/** @param big A string. - * @param little A string which is the same length as, or shorter than, big. - * @return true if `big' starts with `little'. - */ -bool -libdcp::starts_with (string big, string little) -{ - if (little.size() > big.size()) { - return false; - } - - return big.substr (0, little.length()) == little; -} - -/** @param big A string. - * @param little A string which is the same length as, or shorter than, big. - * @return true if `big' ends with `little'. - */ -bool -libdcp::ends_with (string big, string little) -{ - if (little.size() > big.size()) { - return false; - } - - return big.compare (big.length() - little.length(), little.length(), little) == 0; -} - /** Decompress a JPEG2000 image to a bitmap. * @param data JPEG2000 data. * @param size Size of data in bytes. @@ -34,8 +34,6 @@ extern std::string make_uuid (); extern std::string make_digest (std::string filename); extern std::string content_kind_to_string (ContentKind kind); extern ContentKind content_kind_from_string (std::string kind); -extern bool starts_with (std::string big, std::string little); -extern bool ends_with (std::string big, std::string little); extern bool empty_or_white_space (std::string s); extern opj_image_t* decompress_j2k (uint8_t* data, int64_t size, int reduce); extern boost::shared_ptr<ARGBFrame> xyz_to_rgb (opj_image_t* xyz_frame); |
