diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-07-28 16:43:28 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-07-28 16:43:28 +0100 |
| commit | e4d5298e7a179d4103581cba05cbc516f94acf60 (patch) | |
| tree | 0b9c8cb6ad65917f6a3bf76f5a55ec648bdb0e42 /src | |
| parent | 5eb63969c5b6f26ea820cfab116d4aecb6bd3390 (diff) | |
| parent | dc52dfc8e5a5e89005098bbec56331f9f0c6d3aa (diff) | |
Merge branch '1.0' of git.carlh.net:git/libdcp into 1.0
Diffstat (limited to 'src')
| -rw-r--r-- | src/certificate.cc | 3 | ||||
| -rw-r--r-- | src/certificate_chain.cc | 12 | ||||
| -rw-r--r-- | src/compose.hpp | 32 | ||||
| -rw-r--r-- | src/cpl.cc | 7 | ||||
| -rw-r--r-- | src/dcp.cc | 2 | ||||
| -rw-r--r-- | src/dcp_time.cc | 2 | ||||
| -rw-r--r-- | src/decrypted_kdm.cc | 7 | ||||
| -rw-r--r-- | src/key.cc | 5 | ||||
| -rw-r--r-- | src/metadata.cc | 1 | ||||
| -rw-r--r-- | src/mono_picture_asset_writer.cc | 2 | ||||
| -rw-r--r-- | src/mono_picture_asset_writer.h | 1 | ||||
| -rw-r--r-- | src/picture_asset.cc | 6 | ||||
| -rw-r--r-- | src/picture_asset_writer.cc | 2 | ||||
| -rw-r--r-- | src/picture_asset_writer.h | 1 | ||||
| -rw-r--r-- | src/raw_convert.h | 4 | ||||
| -rw-r--r-- | src/reel_asset.cc | 9 | ||||
| -rw-r--r-- | src/reel_picture_asset.cc | 1 | ||||
| -rw-r--r-- | src/smpte_subtitle_asset.cc | 6 | ||||
| -rw-r--r-- | src/sound_asset.cc | 3 | ||||
| -rw-r--r-- | src/stereo_picture_asset_writer.cc | 2 | ||||
| -rw-r--r-- | src/subtitle_asset.cc | 4 | ||||
| -rw-r--r-- | src/types.cc | 2 | ||||
| -rw-r--r-- | src/util.cc | 2 |
23 files changed, 37 insertions, 79 deletions
diff --git a/src/certificate.cc b/src/certificate.cc index 18249a58..34f79754 100644 --- a/src/certificate.cc +++ b/src/certificate.cc @@ -55,7 +55,6 @@ using std::list; using std::string; using std::ostream; using std::min; -using std::stringstream; using namespace dcp; static string const begin_certificate = "-----BEGIN CERTIFICATE-----"; @@ -104,7 +103,7 @@ Certificate::read_string (string cert) See http://comments.gmane.org/gmane.comp.encryption.openssl.user/55593 */ - stringstream s (cert); + locked_stringstream s (cert); string line; /* BEGIN */ diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc index 0046fe75..2ba70183 100644 --- a/src/certificate_chain.cc +++ b/src/certificate_chain.cc @@ -55,13 +55,11 @@ #include <boost/algorithm/string.hpp> #include <boost/foreach.hpp> #include <fstream> -#include <sstream> using std::string; using std::ofstream; using std::ifstream; using std::runtime_error; -using std::stringstream; using namespace dcp; /** Run a shell command. @@ -108,7 +106,7 @@ command (string cmd) int const code = WEXITSTATUS (r); #endif if (code) { - stringstream s; + locked_stringstream s; s << "error " << code << " in " << cmd << " within " << boost::filesystem::current_path(); throw dcp::MiscError (s.str()); } @@ -125,7 +123,7 @@ public_key_digest (boost::filesystem::path private_key, boost::filesystem::path boost::filesystem::path public_name = private_key.string() + ".public"; /* Create the public key from the private key */ - stringstream s; + locked_stringstream s; s << "\"" << openssl.string() << "\" rsa -outform PEM -pubout -in " << private_key.string() << " -out " << public_name.string (); command (s.str().c_str ()); @@ -222,7 +220,7 @@ CertificateChain::CertificateChain ( "/dnQualifier=" + public_key_digest ("ca.key", openssl); { - stringstream c; + locked_stringstream c; c << quoted_openssl << " req -new -x509 -sha256 -config ca.cnf -days 3650 -set_serial 5" << " -subj \"" << ca_subject << "\" -key ca.key -outform PEM -out ca.self-signed.pem"; @@ -253,7 +251,7 @@ CertificateChain::CertificateChain ( "/dnQualifier=" + public_key_digest ("intermediate.key", openssl); { - stringstream s; + locked_stringstream s; s << quoted_openssl << " req -new -config intermediate.cnf -days 3649 -subj \"" << inter_subject << "\" -key intermediate.key -out intermediate.csr"; command (s.str().c_str()); @@ -290,7 +288,7 @@ CertificateChain::CertificateChain ( "/dnQualifier=" + public_key_digest ("leaf.key", openssl); { - stringstream s; + locked_stringstream s; s << quoted_openssl << " req -new -config leaf.cnf -days 3648 -subj \"" << leaf_subject << "\" -key leaf.key -outform PEM -out leaf.csr"; command (s.str().c_str()); } diff --git a/src/compose.hpp b/src/compose.hpp index f7bd4282..185e00a4 100644 --- a/src/compose.hpp +++ b/src/compose.hpp @@ -33,7 +33,7 @@ #ifndef STRING_COMPOSE_H #define STRING_COMPOSE_H -#include <sstream> +#include <locked_sstream.h> #include <string> #include <list> #include <map> // for multimap @@ -58,7 +58,7 @@ namespace StringPrivate std::string str() const; private: - std::ostringstream os; + locked_stringstream os; int arg_no; // we store the output as a list - when the output string is requested, the @@ -106,7 +106,7 @@ namespace StringPrivate case '8': case '9': return true; - + default: return false; } @@ -120,21 +120,21 @@ namespace StringPrivate os << obj; std::string rep = os.str(); - + if (!rep.empty()) { // manipulators don't produce output for (specification_map::const_iterator i = specs.lower_bound(arg_no), end = specs.upper_bound(arg_no); i != end; ++i) { output_list::iterator pos = i->second; ++pos; - + output.insert(pos, rep); } - + os.str(std::string()); //os.clear(); ++arg_no; } - + return *this; } @@ -142,7 +142,7 @@ namespace StringPrivate : arg_no(1) { std::string::size_type b = 0, i = 0; - + // fill in output with the strings between the %1 %2 %3 etc. and // fill in specs with the positions while (i < fmt.length()) { @@ -154,7 +154,7 @@ namespace StringPrivate else if (is_number(fmt[i + 1])) { // aha! a spec! // save string output.push_back(fmt.substr(b, i - b)); - + int n = 1; // number of digits int spec_no = 0; @@ -167,9 +167,9 @@ namespace StringPrivate spec_no /= 10; output_list::iterator pos = output.end(); --pos; // safe since we have just inserted a string> - + specs.insert(specification_map::value_type(spec_no, pos)); - + // jump over spec string i += n; b = i; @@ -180,7 +180,7 @@ namespace StringPrivate else ++i; } - + if (i - b > 0) // add the rest of the string output.push_back(fmt.substr(b, i - b)); } @@ -189,17 +189,17 @@ namespace StringPrivate { // assemble string std::string str; - + for (output_list::const_iterator i = output.begin(), end = output.end(); i != end; ++i) str += *i; - + return str; } } // now for the real thing(s) -namespace String +namespace String { // a series of functions which accept a format string on the form "text %1 // more %2 less %3" and a number of templated parameters and spits out the @@ -310,7 +310,7 @@ namespace String .arg(o10); return c.str(); } - + template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11> @@ -49,8 +49,6 @@ #include <boost/foreach.hpp> using std::string; -using std::stringstream; -using std::ostream; using std::list; using std::pair; using std::make_pair; @@ -207,9 +205,8 @@ CPL::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler not } if (_annotation_text != other_cpl->_annotation_text && !opt.cpl_annotation_texts_can_differ) { - stringstream s; - s << "CPL: annotation texts differ: " << _annotation_text << " vs " << other_cpl->_annotation_text << "\n"; - note (DCP_ERROR, s.str ()); + string const s = "CPL: annotation texts differ: " + _annotation_text + " vs " + other_cpl->_annotation_text + "\n"; + note (DCP_ERROR, s); return false; } @@ -62,12 +62,10 @@ #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> #include <boost/foreach.hpp> -#include <iostream> using std::string; using std::list; using std::cout; -using std::ostream; using std::make_pair; using std::map; using std::cout; diff --git a/src/dcp_time.cc b/src/dcp_time.cc index 401abb3c..526c784c 100644 --- a/src/dcp_time.cc +++ b/src/dcp_time.cc @@ -330,7 +330,7 @@ dcp::operator/ (Time a, Time const & b) string Time::as_string (Standard standard) const { - stringstream str; + locked_stringstream str; str << setw(2) << setfill('0') << h << ":" << setw(2) << setfill('0') << m << ":" << setw(2) << setfill('0') << s << ":"; diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc index abe12a32..4ffad923 100644 --- a/src/decrypted_kdm.cc +++ b/src/decrypted_kdm.cc @@ -52,7 +52,6 @@ using std::list; using std::vector; using std::string; -using std::stringstream; using std::setw; using std::setfill; using std::hex; @@ -79,7 +78,7 @@ put_uuid (uint8_t ** d, string id) { id.erase (std::remove (id.begin(), id.end(), '-')); for (int i = 0; i < 32; i += 2) { - stringstream s; + locked_stringstream s; s << id[i] << id[i + 1]; int h; s >> hex >> h; @@ -91,7 +90,7 @@ put_uuid (uint8_t ** d, string id) static string get_uuid (unsigned char ** p) { - stringstream g; + locked_stringstream g; for (int i = 0; i < 16; ++i) { g << setw(2) << setfill('0') << hex << static_cast<int> (**p); @@ -301,7 +300,7 @@ DecryptedKDM::encrypt (shared_ptr<const CertificateChain> signer, Certificate re char out[encrypted_len * 2]; Kumu::base64encode (encrypted, encrypted_len, out, encrypted_len * 2); int const N = strlen (out); - stringstream lines; + locked_stringstream lines; for (int i = 0; i < N; ++i) { if (i > 0 && (i % 64) == 0) { lines << "\n"; @@ -36,15 +36,14 @@ */ #include "key.h" +#include <locked_sstream.h> #include <asdcp/AS_DCP.h> #include <asdcp/KM_prng.h> #include <asdcp/KM_util.h> -#include <sstream> #include <string> #include <iomanip> using std::string; -using std::stringstream; using std::setw; using std::setfill; using namespace dcp; @@ -94,7 +93,7 @@ Key::operator= (Key const & other) string Key::hex () const { - stringstream g; + locked_stringstream g; for (unsigned int i = 0; i < ASDCP::KeyLen; ++i) { g << setw(2) << setfill('0') << std::hex << static_cast<int> (_value[i]); diff --git a/src/metadata.cc b/src/metadata.cc index 0e3d7c76..dbe80919 100644 --- a/src/metadata.cc +++ b/src/metadata.cc @@ -39,7 +39,6 @@ #include "util.h" #include "local_time.h" #include <asdcp/AS_DCP.h> -#include <sstream> #include <iomanip> #include <time.h> diff --git a/src/mono_picture_asset_writer.cc b/src/mono_picture_asset_writer.cc index 7c955c1d..1ef079dc 100644 --- a/src/mono_picture_asset_writer.cc +++ b/src/mono_picture_asset_writer.cc @@ -44,8 +44,6 @@ #include "picture_asset_writer_common.cc" -using std::istream; -using std::ostream; using std::string; using boost::shared_ptr; using namespace dcp; diff --git a/src/mono_picture_asset_writer.h b/src/mono_picture_asset_writer.h index e694e085..532f7ad7 100644 --- a/src/mono_picture_asset_writer.h +++ b/src/mono_picture_asset_writer.h @@ -43,7 +43,6 @@ #include <boost/utility.hpp> #include <stdint.h> #include <string> -#include <fstream> namespace dcp { diff --git a/src/picture_asset.cc b/src/picture_asset.cc index 674180c3..a0a7d7d7 100644 --- a/src/picture_asset.cc +++ b/src/picture_asset.cc @@ -45,19 +45,13 @@ #include <boost/filesystem.hpp> #include <list> #include <stdexcept> -#include <iostream> -#include <sstream> using std::string; -using std::ostream; using std::list; using std::vector; using std::max; -using std::stringstream; using std::pair; using std::make_pair; -using std::istream; -using std::cout; using boost::shared_ptr; using namespace dcp; diff --git a/src/picture_asset_writer.cc b/src/picture_asset_writer.cc index baa98a4f..e3d7b70e 100644 --- a/src/picture_asset_writer.cc +++ b/src/picture_asset_writer.cc @@ -39,8 +39,6 @@ #include <inttypes.h> #include <stdint.h> -using std::istream; -using std::ostream; using std::string; using boost::shared_ptr; using namespace dcp; diff --git a/src/picture_asset_writer.h b/src/picture_asset_writer.h index 5527537d..1ef519ba 100644 --- a/src/picture_asset_writer.h +++ b/src/picture_asset_writer.h @@ -45,7 +45,6 @@ #include <boost/utility.hpp> #include <stdint.h> #include <string> -#include <fstream> namespace dcp { diff --git a/src/raw_convert.h b/src/raw_convert.h index 36d578b4..5fc05c12 100644 --- a/src/raw_convert.h +++ b/src/raw_convert.h @@ -34,7 +34,7 @@ #ifndef LIBDCP_RAW_CONVERT_H #define LIBDCP_RAW_CONVERT_H -#include <sstream> +#include <locked_sstream.h> #include <iomanip> namespace dcp { @@ -46,7 +46,7 @@ template <typename P, typename Q> P raw_convert (Q v, int precision = 16, bool fixed = false) { - std::stringstream s; + locked_stringstream s; s.imbue (std::locale::classic ()); s << std::setprecision (precision); if (fixed) { diff --git a/src/reel_asset.cc b/src/reel_asset.cc index c4432f21..6e1b024e 100644 --- a/src/reel_asset.cc +++ b/src/reel_asset.cc @@ -41,12 +41,10 @@ #include "compose.hpp" #include <libcxml/cxml.h> #include <libxml++/libxml++.h> -#include <iostream> using std::pair; using std::cout; using std::string; -using std::stringstream; using std::make_pair; using boost::shared_ptr; using namespace dcp; @@ -122,13 +120,12 @@ bool ReelAsset::equals (shared_ptr<const ReelAsset> other, EqualityOptions opt, NoteHandler note) const { if (_annotation_text != other->_annotation_text) { - stringstream s; - s << "Reel: annotation texts differ (" << _annotation_text << " vs " << other->_annotation_text << ")\n"; + string const s = "Reel: annotation texts differ (" + _annotation_text + " vs " + other->_annotation_text + ")\n"; if (!opt.reel_annotation_texts_can_differ) { - note (DCP_ERROR, s.str ()); + note (DCP_ERROR, s); return false; } else { - note (DCP_NOTE, s.str ()); + note (DCP_NOTE, s); } } diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc index 1c745e4a..de106c79 100644 --- a/src/reel_picture_asset.cc +++ b/src/reel_picture_asset.cc @@ -47,7 +47,6 @@ using std::bad_cast; using std::string; -using std::stringstream; using boost::shared_ptr; using boost::dynamic_pointer_cast; using boost::optional; diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index 5bb88621..0c0181f4 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -52,8 +52,6 @@ using std::string; using std::list; -using std::stringstream; -using std::cout; using std::vector; using std::map; using boost::shared_ptr; @@ -85,9 +83,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file) if (!ASDCP_FAILURE (r)) { string s; reader->ReadTimedTextResource (s, 0, 0); - stringstream t; - t << s; - xml->read_stream (t); + xml->read_string (s); ASDCP::WriterInfo info; reader->FillWriterInfo (info); _id = read_writer_info (info); diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 613fa576..e3adff45 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -47,12 +47,9 @@ #include <asdcp/AS_DCP.h> #include <libxml++/nodes/element.h> #include <boost/filesystem.hpp> -#include <iostream> #include <stdexcept> using std::string; -using std::stringstream; -using std::ostream; using std::vector; using std::list; using boost::shared_ptr; diff --git a/src/stereo_picture_asset_writer.cc b/src/stereo_picture_asset_writer.cc index d98df6ae..6e43de10 100644 --- a/src/stereo_picture_asset_writer.cc +++ b/src/stereo_picture_asset_writer.cc @@ -40,8 +40,6 @@ #include "picture_asset_writer_common.cc" -using std::istream; -using std::ostream; using std::string; using boost::shared_ptr; using namespace dcp; diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index cb757673..b9f6336c 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -45,13 +45,9 @@ #include <boost/algorithm/string.hpp> #include <boost/shared_array.hpp> #include <boost/foreach.hpp> -#include <fstream> using std::string; using std::list; -using std::ostream; -using std::ofstream; -using std::stringstream; using std::cout; using std::cerr; using std::map; diff --git a/src/types.cc b/src/types.cc index cbb56e7f..cf3229df 100644 --- a/src/types.cc +++ b/src/types.cc @@ -121,7 +121,7 @@ Colour::Colour (string argb_hex) string Colour::to_argb_string () const { - stringstream s; + locked_stringstream s; s << "FF"; s << hex << setw(2) << setfill('0') << r diff --git a/src/util.cc b/src/util.cc index 359ac317..0c3cea08 100644 --- a/src/util.cc +++ b/src/util.cc @@ -55,14 +55,12 @@ #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> #include <stdexcept> -#include <sstream> #include <iostream> #include <iomanip> using std::string; using std::wstring; using std::cout; -using std::stringstream; using std::min; using std::max; using std::list; |
