Merge master.
[dcpomatic.git] / src / lib / update.cc
index 019db8e761ea619c26848ec822c16b517f363ea1..c50022091fbe3ab6abb0169e86fa00e7444c4cb3 100644 (file)
 */
 
 #include <string>
-#include <sstream>
 #include <boost/algorithm/string.hpp>
 #include <curl/curl.h>
 #include <libcxml/cxml.h>
+#include <dcp/raw_convert.h>
 #include "update.h"
 #include "version.h"
 #include "ui_signaller.h"
+#include "safe_stringstream.h"
 
 #define BUFFER_SIZE 1024
 
 using std::cout;
 using std::min;
 using std::string;
-using std::stringstream;
-using boost::lexical_cast;
+using dcp::raw_convert;
 
 /** Singleton instance */
 UpdateChecker* UpdateChecker::_instance = 0;
@@ -89,7 +89,7 @@ UpdateChecker::run ()
 void
 UpdateChecker::thread ()
 {
-       while (1) {
+       while (true) {
                /* Block until there is something to do */
                boost::mutex::scoped_lock lock (_process_mutex);
                while (_to_do == 0) {
@@ -112,10 +112,9 @@ UpdateChecker::thread ()
                        /* Parse the reply */
                        
                        _buffer[_offset] = '\0';
-                       stringstream s;
-                       s << _buffer;
+                       string s (_buffer);
                        cxml::Document doc ("Update");
-                       doc.read_stream (s);
+                       doc.read_string (s);
                        
                        {
                                boost::mutex::scoped_lock lm (_data_mutex);
@@ -130,12 +129,12 @@ UpdateChecker::thread ()
                                current_pre = true;
                        }
                        
-                       float current_float = lexical_cast<float> (current);
+                       float current_float = raw_convert<float> (current);
                        if (current_pre) {
                                current_float -= 0.005;
                        }
                        
-                       if (current_float < lexical_cast<float> (_stable)) {
+                       if (current_float < raw_convert<float> (_stable)) {
                                set_state (YES);
                        } else {
                                set_state (NO);