Use boost starts/ends with methods.
authorCarl Hetherington <cth@carlh.net>
Sun, 13 Jan 2013 13:46:20 +0000 (13:46 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 13 Jan 2013 13:46:20 +0000 (13:46 +0000)
src/asset_map.cc
src/dcp.cc
src/util.cc
src/util.h

index 4fda0a899aaad86d5014f7191b3755afddf14672..8fcc515f037241d7e8d30b45c508e04877fcb960 100644 (file)
@@ -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());
        }
        
index edb247a51970abf9977d2e77ddbf701d558de8be..6c62693954ba4bca297486e928226969fb2006a8 100644 (file)
@@ -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;
                }
 
index ca621a445cdafc25fc8f5e38e8d958bb289a030d..6769cc41f86debfbf31555c30c59e068c6e0af9d 100644 (file)
@@ -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.
index 14893065c8d4606444eb5da5b5fda280207355dc..721d11385beccfc08b7ddf1ef23f533329c86ec4 100644 (file)
@@ -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);