Use String::compose in a few places.
authorCarl Hetherington <cth@carlh.net>
Tue, 2 Oct 2012 15:13:29 +0000 (16:13 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 2 Oct 2012 15:13:29 +0000 (16:13 +0100)
15 files changed:
src/lib/ab_transcode_job.cc
src/lib/check_hashes_job.cc
src/lib/dcp_video_frame.cc
src/lib/examine_content_job.cc
src/lib/film.cc
src/lib/j2k_wav_encoder.cc
src/lib/job.cc
src/lib/make_dcp_job.cc
src/lib/scp_dcp_job.cc
src/lib/server.cc
src/lib/thumbs_job.cc
src/lib/transcode_job.cc
src/wx/film_editor.cc
src/wx/job_manager_view.cc
src/wx/job_wrapper.cc

index 1a6104251040036b33c2357acb42075e6d2fa3a5..d94f56d0a4c0a46538fc19d3e437273a3ff4b4bf 100644 (file)
@@ -46,9 +46,7 @@ ABTranscodeJob::ABTranscodeJob (shared_ptr<const FilmState> s, shared_ptr<const
 string
 ABTranscodeJob::name () const
 {
-       stringstream s;
-       s << "A/B transcode " << _fs->name;
-       return s.str ();
+       return String::compose ("A/B transcode %1", _fs->name);
 }
 
 void
index 5a927f752bb5815517dfb488787545849884dbe3..cf269564aa7f2dc81717907249e087fef2c5d835 100644 (file)
@@ -41,9 +41,7 @@ CheckHashesJob::CheckHashesJob (shared_ptr<const FilmState> s, shared_ptr<const
 string
 CheckHashesJob::name () const
 {
-       stringstream s;
-       s << "Check hashes of " << _fs->name;
-       return s.str ();
+       return String::compose ("Check hashes of %1", _fs->name);
 }
 
 void
index da7133c4ba2a7f6552d76819dd7acc01ab22cac8..90826a99f5a1ea04c5633c43205c89766cc0e4c6 100644 (file)
@@ -262,11 +262,7 @@ DCPVideoFrame::encode_locally ()
                throw EncodeError ("jpeg2000 encoding failed");
        }
 
-       {
-               stringstream s;
-               s << "Finished locally-encoded frame " << _frame;
-               _log->log (s.str ());
-       }
+       _log->log (String::compose ("Finished locally-encoded frame %1", _frame));
        
        return shared_ptr<EncodedData> (new LocallyEncodedData (_cio->buffer, cio_tell (_cio)));
 }
@@ -318,11 +314,7 @@ DCPVideoFrame::encode_remotely (ServerDescription const * serv)
        /* now read the rest */
        socket.read_definite_and_consume (e->data(), e->size(), 30);
 
-       {
-               stringstream s;
-               s << "Finished remotely-encoded frame " << _frame;
-               _log->log (s.str ());
-       }
+       _log->log (String::compose ("Finished remotely-encoded frame %1", _frame));
        
        return e;
 }
index 6927715bdfdba93b45b8d9b017be0978dec3de98..d77ede2f91abf1d1c0d0d9348ed19247429a3272 100644 (file)
@@ -43,9 +43,7 @@ ExamineContentJob::~ExamineContentJob ()
 string
 ExamineContentJob::name () const
 {
-       stringstream s;
-       s << "Examine content of " << _fs->name;
-       return s.str ();
+       return String::compose ("Examine content of %1", _fs->name);
 }
 
 void
index 583a15e19cc472af6ae2ecca5c73077b174ecd17..90c410546184fe3c86e2db914388f5ae131b119e 100644 (file)
@@ -483,18 +483,12 @@ Film::make_dcp (bool transcode, int freq)
                throw BadSettingError ("name", "cannot contain slashes");
        }
        
-       {
-               stringstream s;
-               s << "DVD-o-matic " << DVDOMATIC_VERSION << " using " << dependency_version_summary ();
-               log()->log (s.str ());
-       }
+       log()->log (String::compose ("DVD-o-matic %1 using %2", DVDOMATIC_VERSION, dependency_version_summary()));
 
        {
                char buffer[128];
                gethostname (buffer, sizeof (buffer));
-               stringstream s;
-               s << "Starting to make a DCP on " << buffer;
-               log()->log (s.str ());
+               log()->log (String::compose ("Starting to make DCP on %1", buffer));
        }
                
        if (format() == 0) {
index 73aa1bff2023833ea9afcc519f2f3d95ef66b948..08c796350c54746b586fb8b6706e98a69936b534 100644 (file)
@@ -169,9 +169,7 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server)
                                encoded = vf->encode_remotely (server);
 
                                if (remote_backoff > 0) {
-                                       stringstream s;
-                                       s << server->host_name() << " was lost, but now she is found; removing backoff";
-                                       _log->log (s.str ());
+                                       _log->log (String::compose ("%1 was lost, but now she is found; removing backoff", server->host_name ()));
                                }
                                
                                /* This job succeeded, so remove any backoff */
@@ -182,9 +180,11 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server)
                                        /* back off more */
                                        remote_backoff += 10;
                                }
-                               stringstream s;
-                               s << "Remote encode of " << vf->frame() << " on " << server->host_name() << " failed (" << e.what() << "); thread sleeping for " << remote_backoff << "s.";
-                               _log->log (s.str ());
+                               _log->log (
+                                       String::compose (
+                                               "Remote encode of %1 on %2 failed (%3); thread sleeping for %4s",
+                                               vf->frame(), server->host_name(), e.what(), remote_backoff)
+                                       );
                        }
                                
                } else {
@@ -193,9 +193,7 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server)
                                encoded = vf->encode_locally ();
                                TIMING ("encoder thread %1 finishes local encode of %2", pthread_self(), vf->frame());
                        } catch (std::exception& e) {
-                               stringstream s;
-                               s << "Local encode failed " << e.what() << ".";
-                               _log->log (s.str ());
+                               _log->log (String::compose ("Local encode failed (%1)", e.what ()));
                        }
                }
 
@@ -263,17 +261,13 @@ J2KWAVEncoder::process_end ()
        */
 
        for (list<shared_ptr<DCPVideoFrame> >::iterator i = _queue.begin(); i != _queue.end(); ++i) {
-               stringstream s;
-               s << "Encode left-over frame " << (*i)->frame();
-               _log->log (s.str ());
+               _log->log (String::compose ("Encode left-over frame %1", (*i)->frame ()));
                try {
                        shared_ptr<EncodedData> e = (*i)->encode_locally ();
                        e->write (_opt, (*i)->frame ());
                        frame_done ((*i)->frame ());
                } catch (std::exception& e) {
-                       stringstream s;
-                       s << "Local encode failed " << e.what() << ".";
-                       _log->log (s.str ());
+                       _log->log (String::compose ("Local encode failed (%1)", e.what ()));
                }
        }
        
index e78a9131581e6183ceefc2fb96ac20a4b28f421e..39ce4173a78a8af19621e5f4f31f95a946ea170c 100644 (file)
@@ -69,9 +69,7 @@ Job::run_wrapper ()
                
                set_progress (1);
                set_state (FINISHED_ERROR);
-               stringstream s;
-               s << e.what() << "(" << filesystem::path (e.filename()).leaf() << ")";
-               set_error (s.str ());
+               set_error (String::compose ("%1 (%2)", e.what(), filesystem::path (e.filename()).leaf()));
                
        } catch (std::exception& e) {
 
index 8d3547cae8d0808422bef01877fbe1682dcfd9bc..ae4bb4fbed2ae266f16db966ed002ab31152c506 100644 (file)
@@ -52,9 +52,7 @@ MakeDCPJob::MakeDCPJob (shared_ptr<const FilmState> s, shared_ptr<const Options>
 string
 MakeDCPJob::name () const
 {
-       stringstream s;
-       s << "Make DCP for " << _fs->name;
-       return s.str ();
+       return String::compose ("Make DCP for %1", _fs->name);
 }
 
 string
index f62d2db8dd86bb78be6e440319ff0ae8dbb8a06d..dac4a602c556b43fc70428743e77342bd4b5245d 100644 (file)
@@ -78,9 +78,7 @@ public:
        {
                scp = ssh_scp_new (s, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, Config::instance()->tms_path().c_str ());
                if (!scp) {
-                       stringstream s;
-                       s << "Could not start SCP session (" << ssh_get_error (s) << ")";
-                       throw NetworkError (s.str ());
+                       throw NetworkError (String::compose ("Could not start SCP session (%1)", ssh_get_error (s)));
                }
        }
 
@@ -103,9 +101,7 @@ SCPDCPJob::SCPDCPJob (shared_ptr<const FilmState> s, Log* l)
 string
 SCPDCPJob::name () const
 {
-       stringstream s;
-       s << "Copy DCP to TMS";
-       return s.str ();
+       return "Copy DCP to TMS";
 }
 
 void
@@ -124,39 +120,29 @@ SCPDCPJob::run ()
        
        int r = ss.connect ();
        if (r != SSH_OK) {
-               stringstream s;
-               s << "Could not connect to server " << Config::instance()->tms_ip() << " (" << ssh_get_error (ss.session) << ")";
-               throw NetworkError (s.str ());
+               throw NetworkError (String::compose ("Could not connect to server %1 (%2)", Config::instance()->tms_ip(), ssh_get_error (ss.session)));
        }
        
        int const state = ssh_is_server_known (ss.session);
        if (state == SSH_SERVER_ERROR) {
-               stringstream s;
-               s << "SSH error (" << ssh_get_error (ss.session) << ")";
-               throw NetworkError (s.str ());
+               throw NetworkError (String::compose ("SSH error (%1)", ssh_get_error (ss.session)));
        }
        
        r = ssh_userauth_password (ss.session, 0, Config::instance()->tms_password().c_str ());
        if (r != SSH_AUTH_SUCCESS) {
-               stringstream s;
-               s << "Failed to authenticate with server (" << ssh_get_error (ss.session) << ")";
-               throw NetworkError (s.str ());
+               throw NetworkError (String::compose ("Failed to authenticate with server (%1)", ssh_get_error (ss.session)));
        }
        
        SSHSCP sc (ss.session);
        
        r = ssh_scp_init (sc.scp);
        if (r != SSH_OK) {
-               stringstream s;
-               s << "Could not start SCP session (" << ssh_get_error (ss.session) << ")";
-               throw NetworkError (s.str ());
+               throw NetworkError (String::compose ("Could not start SCP session (%1)", ssh_get_error (ss.session)));
        }
        
        r = ssh_scp_push_directory (sc.scp, _fs->name.c_str(), S_IRWXU);
        if (r != SSH_OK) {
-               stringstream s;
-               s << "Could not create remote directory " << _fs->name << "(" << ssh_get_error (ss.session) << ")";
-               throw NetworkError (s.str ());
+               throw NetworkError (String::compose ("Could not create remote directory %1 (%2)", _fs->name, ssh_get_error (ss.session)));
        }
        
        string const dcp_dir = _fs->dir (_fs->name);
@@ -186,9 +172,7 @@ SCPDCPJob::run ()
 
                FILE* f = fopen (filesystem::path (*i).string().c_str(), "rb");
                if (f == 0) {
-                       stringstream s;
-                       s << "Could not open " << *i << " to send";
-                       throw NetworkError (s.str ());
+                       throw NetworkError (String::compose ("Could not open %1 to send", *i));
                }
 
                while (to_do > 0) {
@@ -200,9 +184,7 @@ SCPDCPJob::run ()
                        
                        r = ssh_scp_write (sc.scp, buffer, t);
                        if (r != SSH_OK) {
-                               stringstream s;
-                               s << "Could not write to remote file (" << ssh_get_error (ss.session) << ")";
-                               throw NetworkError (s.str ());
+                               throw NetworkError (String::compose ("Could not write to remote file (%1)", ssh_get_error (ss.session)));
                        }
                        to_do -= t;
                        bytes_transferred += t;
index f8c4425d991f42b4a538e2593b198514ddcd491c..28236e3e04804e39ccab9b5167e7d2de7101f193 100644 (file)
@@ -163,9 +163,7 @@ Server::worker_thread ()
                if (frame >= 0) {
                        struct timeval end;
                        gettimeofday (&end, 0);
-                       stringstream s;
-                       s << "Encoded frame " << frame << " in " << (seconds (end) - seconds (start));
-                       _log->log (s.str ());
+                       _log->log (String::compose ("Encoded frame %1 in %2", frame, seconds (end) - seconds (start)));
                }
                
                _worker_condition.notify_all ();
@@ -175,9 +173,7 @@ Server::worker_thread ()
 void
 Server::run (int num_threads)
 {
-       stringstream s;
-       s << "Server starting with " << num_threads << " threads.";
-       _log->log (s.str ());
+       _log->log (String::compose ("Server starting with %1 threads", num_threads));
        
        for (int i = 0; i < num_threads; ++i) {
                _worker_threads.push_back (new thread (bind (&Server::worker_thread, this)));
index 0eb116fd1ea234f709ec03ecf1d24e3b1e9b75e9..f6ed75ff7cd73efdecaddb0d1708f2b60d25faff 100644 (file)
@@ -44,9 +44,7 @@ ThumbsJob::ThumbsJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o
 string
 ThumbsJob::name () const
 {
-       stringstream s;
-       s << "Update thumbs for " << _fs->name;
-       return s.str ();
+       return String::compose ("Update thumbs for %1", _fs->name);
 }
 
 void
index 9113593f0c1976c4967df5df7e9c7bea509d38d4..e79be09feb04779d8603c20bbd2bc881b9fc09b2 100644 (file)
@@ -48,9 +48,7 @@ TranscodeJob::TranscodeJob (shared_ptr<const FilmState> s, shared_ptr<const Opti
 string
 TranscodeJob::name () const
 {
-       stringstream s;
-       s << "Transcode " << _fs->name;
-       return s.str ();
+       return String::compose ("Transcode %1", _fs->name);
 }
 
 void
@@ -70,12 +68,9 @@ TranscodeJob::run ()
 
        } catch (std::exception& e) {
 
-               stringstream s;
                set_progress (1);
                set_state (FINISHED_ERROR);
-
-               s << "Transcode job failed (" << e.what() << ")";
-               _log->log (s.str ());
+               _log->log (String::compose ("Transcode job failed (%1)", e.what()));
 
                throw;
        }
index 6de3af9e70d6a8d7d2d9e00b53dd891197a5d996..9171daa5c2d093acd0111111bd581dd0f64a5744 100644 (file)
@@ -289,9 +289,7 @@ FilmEditor::content_changed (wxCommandEvent &)
                _film->set_content (wx_to_std (_content->GetPath ()));
        } catch (std::exception& e) {
                _content->SetPath (std_to_wx (_film->directory ()));
-               stringstream m;
-               m << "Could not set content: " << e.what() << ".";
-               error_dialog (this, m.str ());
+               error_dialog (this, String::compose ("Could not set content: %1", e.what ()));
        }
 
        _ignore_changes = Film::NONE;
index 1d5c855eada8a990b0cf57dfbd2e89556738faf8..97da3936fdd4b96e1e4ba547fe7bdcd407aacfbd 100644 (file)
@@ -111,9 +111,7 @@ JobManagerView::update ()
                        try {
                                (*i)->emit_finished ();
                        } catch (OpenFileError& e) {
-                               stringstream s;
-                               s << "Error: " << e.what();
-                               error_dialog (this, s.str ());
+                               error_dialog (this, String::compose ("Error: %1", e.what ()));
                        }
                        
                        _job_records[*i].informed_of_finish = true;
index ad83aa271da0d8c43d08b7fe6b9b5c67aeeee58e..cc7507547b8172dc9585629ee1b11ba7eb146a64 100644 (file)
@@ -35,12 +35,8 @@ JobWrapper::make_dcp (wxWindow* parent, Film* film, bool transcode)
        try {
                film->make_dcp (transcode);
        } catch (BadSettingError& e) {
-               stringstream s;
-               s << "Bad setting for " << e.setting() << "(" << e.what() << ")";
-               error_dialog (parent, s.str ());
+               error_dialog (parent, String::compose ("Bad setting for %1 (%2)", e.setting(), e.what ()));
        } catch (std::exception& e) {
-               stringstream s;
-               s << "Could not make DCP: " << e.what () << ".";
-               error_dialog (parent, s.str ());
+               error_dialog (parent, String::compose ("Could not make DCP: %1", e.what ()));
        }
 }