From 62ee85a258aa9329544d8542dfbcc40ce8177a7a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 13 Jan 2013 13:46:20 +0000 Subject: Use boost starts/ends with methods. --- src/asset_map.cc | 3 ++- src/dcp.cc | 3 ++- src/util.cc | 28 ---------------------------- 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 #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()); } diff --git a/src/dcp.cc b/src/dcp.cc index edb247a5..6c626939 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -27,6 +27,7 @@ #include #include #include +#include #include #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. diff --git a/src/util.h b/src/util.h index 14893065..721d1138 100644 --- a/src/util.h +++ b/src/util.h @@ -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 xyz_to_rgb (opj_image_t* xyz_frame); -- cgit v1.2.3