From 7cd5c7911a3d4b11445cbec9e56cf52edb96b93f Mon Sep 17 00:00:00 2001 From: "Eric J. Korpela" Date: Wed, 30 Jun 2004 18:17:21 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=3725 --- api/boinc_api.h | 3 +-- apps/upper_case.C | 2 ++ checkin_notes | 16 ++++++++++++++++ client/app.C | 4 ++++ client/app.h | 2 +- client/client_msgs.h | 5 ++--- client/client_state.C | 4 ++++ client/client_state.h | 12 ++++++------ client/client_types.C | 2 ++ client/client_types.h | 24 ++++++++++++------------ client/cpp.h | 1 - client/cs_account.C | 2 ++ client/cs_apps.C | 2 ++ client/cs_files.C | 2 ++ client/cs_prefs.C | 3 +++ client/cs_scheduler.C | 3 +++ client/cs_trickle.C | 2 ++ client/file_xfer.C | 2 ++ client/file_xfer.h | 2 +- client/gui_rpc_client.h | 20 +++++++++----------- client/gui_rpc_server.C | 4 ++++ client/gui_rpc_server.h | 2 +- client/http.C | 4 +++- client/http.h | 6 +++--- client/net_xfer.C | 2 ++ client/net_xfer.h | 2 +- client/pers_file_xfer.C | 2 ++ client/pers_file_xfer.h | 2 +- client/prefs.h | 4 ++-- client/scheduler_op.C | 2 ++ client/scheduler_op.h | 16 ++++++++-------- db/db_base.C | 10 +++++----- db/db_base.h | 2 +- lib/app_ipc.C | 2 ++ lib/base64.C | 2 ++ lib/base64.h | 7 +++---- lib/boinc_win.h | 4 +--- lib/exception.h | 14 ++++++-------- lib/filesys.C | 2 ++ lib/filesys.h | 9 ++++----- lib/miofile.h | 3 +-- lib/parse.h | 9 ++++----- lib/util.h | 15 +++++++-------- sched/assimilate_handler.C | 2 ++ sched/assimilate_handler.h | 3 +-- sched/assimilator.C | 2 ++ sched/db_dump.C | 3 +++ sched/transitioner.C | 4 ++-- sched/validate_test.C | 5 ++++- sched/validate_trivial.C | 2 ++ sched/validate_util.C | 3 +++ sched/validate_util.h | 8 +++----- 52 files changed, 165 insertions(+), 105 deletions(-) diff --git a/api/boinc_api.h b/api/boinc_api.h index e0b3ec7856..0e606bc022 100755 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -24,7 +24,6 @@ // _WIN32" -- if something is not working on a particular version of MSVC // let's find a working solution #include -using namespace std; #include "app_ipc.h" @@ -40,7 +39,7 @@ extern "C" { extern int boinc_resolve_filename(const char*, char*, int len); - extern int boinc_resolve_filename_s(const char*, string&); + extern int boinc_resolve_filename_s(const char*, std::string&); extern int boinc_parse_init_data_file(); extern int boinc_write_init_data_file(); diff --git a/apps/upper_case.C b/apps/upper_case.C index 46c88895de..3c6750ae26 100755 --- a/apps/upper_case.C +++ b/apps/upper_case.C @@ -63,6 +63,8 @@ #include "boinc_api.h" #include "mfile.h" +using std::string; + #define CHECKPOINT_FILE "upper_case_state" #ifdef BOINC_APP_GRAPHICS diff --git a/checkin_notes b/checkin_notes index 0bbf324df4..b72a81116d 100755 --- a/checkin_notes +++ b/checkin_notes @@ -14330,3 +14330,19 @@ Karl 2004-06-30 boinc_setup.vdproj boinc_setup_auto.vdproj +Eric K 30 June 2004 + - Removed "using" directives from header files. "using" + directives should not be used in header files for the following reasons. + - A "using namespace" directive cannot be revoked for any source file + including the header. It forces the use of the namespace regardless of + the consequences. + - Dropping the namespace qualifier on STL templates ambiguates the + resolution of template functions. (How many C libraries or headers + have you seen that define the function min()?) + - Reducing typing is not a good reason to drop namespace qualifiers any + more than it would be a good idea to "#define p printf" + - Namespaces exist for a reason. + - It's acceptable to have "using" directive in a source file, since it + won't affect other files. It's better to have "using std::string;" + directives than "using namespace std;" for hopefully obvious reasons. + diff --git a/client/app.C b/client/app.C index d6145f1f3a..9c3c656293 100644 --- a/client/app.C +++ b/client/app.C @@ -80,6 +80,10 @@ #include "client_msgs.h" #include "app.h" +using std::vector; +using std::max; + + // value for setpriority(2) static const int PROCESS_IDLE_PRIORITY = 19; diff --git a/client/app.h b/client/app.h index 0cc6b66ce3..cb40729c0c 100644 --- a/client/app.h +++ b/client/app.h @@ -157,7 +157,7 @@ public: class ACTIVE_TASK_SET { public: - typedef vector active_tasks_v; + typedef std::vector active_tasks_v; active_tasks_v active_tasks; int remove(ACTIVE_TASK*); ACTIVE_TASK* lookup_pid(int); diff --git a/client/client_msgs.h b/client/client_msgs.h index 189f7d3e17..0de5f3b8f7 100644 --- a/client/client_msgs.h +++ b/client/client_msgs.h @@ -32,7 +32,6 @@ #include #include -using std::string; #include "msg_log.h" @@ -57,10 +56,10 @@ struct MESSAGE_DESC { int priority; int timestamp; int seqno; - string message; + std::string message; }; -extern list message_descs; +extern std::list message_descs; extern void record_message(class PROJECT *p, int priority, int now, char* msg); extern void show_message(class PROJECT *p, char* message, int priority); diff --git a/client/client_state.C b/client/client_state.C index 128ab06f4c..672be67de5 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -58,6 +58,10 @@ #include "client_msgs.h" #include "client_state.h" +using std::max; +using std::string; +using std::vector; + CLIENT_STATE gstate; CLIENT_STATE::CLIENT_STATE() { diff --git a/client/client_state.h b/client/client_state.h index b6c0fdbc05..c317e1a35a 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -66,12 +66,12 @@ enum SUSPEND_REASON_t { // class CLIENT_STATE { public: - vector projects; - vector apps; - vector file_infos; - vector app_versions; - vector workunits; - vector results; + std::vector projects; + std::vector apps; + std::vector file_infos; + std::vector app_versions; + std::vector workunits; + std::vector results; NET_XFER_SET* net_xfers; PERS_FILE_XFER_SET* pers_file_xfers; diff --git a/client/client_types.C b/client/client_types.C index 3bb754ef84..8173a95456 100644 --- a/client/client_types.C +++ b/client/client_types.C @@ -40,6 +40,8 @@ #include "client_types.h" +using std::string; + PROJECT::PROJECT() { init(); } diff --git a/client/client_types.h b/client/client_types.h index d05c66f080..d341b872a9 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -74,13 +74,13 @@ public: RESULT* result; // for upload files (to authenticate) PROJECT* project; int ref_cnt; - vector urls; + std::vector urls; int start_url; int current_url; char signed_xml[MAX_BLOB_LEN]; char xml_signature[MAX_BLOB_LEN]; char file_signature[MAX_BLOB_LEN]; - string error_msg; // if permanent error occurs during file xfer, + std::string error_msg; // if permanent error occurs during file xfer, // it's recorded here FILE_INFO(); @@ -120,12 +120,12 @@ public: char master_url[256]; // url of site that contains scheduler tags // for this project char authenticator[256]; // user's authenticator on this project - string project_prefs; + std::string project_prefs; // without the enclosing tags. // May include elements // This field is used only briefly: between handling a // scheduler RPC reply and writing the account file - string project_specific_prefs; + std::string project_specific_prefs; // without enclosing tags // Does not include elements double resource_share; @@ -135,7 +135,7 @@ public: // They may depend on the host as well as user and project // NOTE: if you add anything, add it to copy_state_fields() also!!! // - vector scheduler_urls; // where to find scheduling servers + std::vector scheduler_urls; // where to find scheduling servers char project_name[256]; // descriptive. not unique char user_name[256]; char team_name[256]; @@ -165,7 +165,7 @@ public: bool anonymous_platform; // app_versions.xml file found in project dir; // use those apps rather then getting from server char code_sign_key[MAX_BLOB_LEN]; - vector user_files; + std::vector user_files; int parse_preferences_for_user_files(); // the following fields used by CPU scheduler @@ -213,7 +213,7 @@ struct APP_VERSION { int version_num; APP* app; PROJECT* project; - vector app_files; + std::vector app_files; int ref_cnt; int parse(MIOFILE&); @@ -228,7 +228,7 @@ struct WORKUNIT { // Instead, the client picks the latest app version char command_line[256]; char env_vars[256]; // environment vars in URL format - vector input_files; + std::vector input_files; PROJECT* project; APP* app; APP_VERSION* avp; @@ -241,14 +241,14 @@ struct WORKUNIT { int parse(MIOFILE&); int write(MIOFILE&); bool had_failure(int& failnum); - void get_file_errors(string&); + void get_file_errors(std::string&); }; struct RESULT { char name[256]; char wu_name[256]; int report_deadline; - vector output_files; + std::vector output_files; bool is_active; // an app is currently running for this. // this is false for preempted tasks! @@ -264,7 +264,7 @@ struct RESULT { int signal; // the signal caught by the active_task, // defined only if active_task_state is PROCESS_SIGNALED int active_task_state; // the state of the active task corresponding to this result - string stderr_out; + std::string stderr_out; // the concatenation of: // // - if report_result_error() is called for this result: @@ -295,7 +295,7 @@ struct RESULT { int parse_ack(FILE*); int write(MIOFILE&, bool to_server); bool is_upload_done(); // files uploaded? - void get_app_version_string(string&); + void get_app_version_string(std::string&); }; int verify_downloaded_file(char* pathname, FILE_INFO& file_info); diff --git a/client/cpp.h b/client/cpp.h index 68aa8df1fc..cb9049689d 100644 --- a/client/cpp.h +++ b/client/cpp.h @@ -26,5 +26,4 @@ #include #include #include -using namespace std; #endif diff --git a/client/cs_account.C b/client/cs_account.C index 8cbf599fe2..019837d5c0 100644 --- a/client/cs_account.C +++ b/client/cs_account.C @@ -33,6 +33,8 @@ #include "error_numbers.h" #include "file_names.h" +using std::string; + static inline string filename_to_project_dirname(const string& filename) { assert(starts_with(filename, "account_")); assert(ends_with(filename, ".xml")); diff --git a/client/cs_apps.C b/client/cs_apps.C index a1b2d91a49..9096f13fad 100644 --- a/client/cs_apps.C +++ b/client/cs_apps.C @@ -44,6 +44,8 @@ #include "client_msgs.h" #include "client_state.h" +using std::vector; + // Quit running applications, quit benchmarks, // write the client_state.xml file diff --git a/client/cs_files.C b/client/cs_files.C index 7ff329f6c3..f15dead052 100644 --- a/client/cs_files.C +++ b/client/cs_files.C @@ -46,6 +46,8 @@ #define MAX_TRANSFERS_PER_PROJECT 2 +using std::vector; + // Decide whether to consider starting a new file transfer // bool CLIENT_STATE::start_new_file_xfer(PERS_FILE_XFER& pfx) { diff --git a/client/cs_prefs.C b/client/cs_prefs.C index 7c6e013a25..81bbb4447f 100644 --- a/client/cs_prefs.C +++ b/client/cs_prefs.C @@ -41,6 +41,9 @@ #include "client_msgs.h" #include "client_state.h" +using std::min; +using std::string; + void CLIENT_STATE::install_global_prefs() { net_xfers->max_bytes_sec_up = global_prefs.max_bytes_sec_up; net_xfers->max_bytes_sec_down = global_prefs.max_bytes_sec_down; diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index 57c997cba5..06cb975ce0 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -47,6 +47,9 @@ #include "client_state.h" +using std::vector; +using std::string; + // quantities like avg CPU time decay by a factor of e every week // #define EXP_DECAY_RATE (1./(SECONDS_PER_DAY*7)) diff --git a/client/cs_trickle.C b/client/cs_trickle.C index 9bda354cb0..7cb237eea8 100644 --- a/client/cs_trickle.C +++ b/client/cs_trickle.C @@ -28,6 +28,8 @@ #include "parse.h" #include "client_state.h" +using std::string; + // Scan project dir for file names of the form trickle_up_X_Y // where X is a result name and Y is a timestamp. // Convert them to XML (for sched request message) diff --git a/client/file_xfer.C b/client/file_xfer.C index eeb7b97780..d68f55fea4 100644 --- a/client/file_xfer.C +++ b/client/file_xfer.C @@ -32,6 +32,8 @@ #include "parse.h" #include "error_numbers.h" +using std::vector; + FILE_XFER::FILE_XFER() { file_xfer_done = false; file_xfer_retval = 0; diff --git a/client/file_xfer.h b/client/file_xfer.h index 873b3939ed..cf350b109e 100644 --- a/client/file_xfer.h +++ b/client/file_xfer.h @@ -53,7 +53,7 @@ public: class FILE_XFER_SET { HTTP_OP_SET* http_ops; public: - vector file_xfers; + std::vector file_xfers; FILE_XFER_SET(HTTP_OP_SET*); int insert(FILE_XFER*); int remove(FILE_XFER*); diff --git a/client/gui_rpc_client.h b/client/gui_rpc_client.h index 67e65e23d1..9ae1c7a58a 100644 --- a/client/gui_rpc_client.h +++ b/client/gui_rpc_client.h @@ -22,8 +22,6 @@ #include #include -using std::string; -using std::vector; #endif #include "miofile.h" @@ -33,7 +31,7 @@ using std::vector; struct PROJECT; struct FILE_INFO { - string name; + std::string name; bool generated_locally; bool uploaded; bool upload_when_present; @@ -165,13 +163,13 @@ class RPC_CLIENT { int send_request(char*); int get_reply(char*&); public: - vector projects; - vector file_infos; - vector apps; - vector app_versions; - vector wus; - vector results; - vector active_tasks; + std::vector projects; + std::vector file_infos; + std::vector apps; + std::vector app_versions; + std::vector wus; + std::vector results; + std::vector active_tasks; APP* lookup_app(string&); WORKUNIT* lookup_wu(string&); @@ -191,7 +189,7 @@ public: int set_run_mode(int mode); int run_benchmarks(); int set_proxy_settings(PROXY_INFO&); - int get_messages(int nmessages, int seqno, vector&); + int get_messages(int nmessages, int seqno, std::vector&); void print(); }; diff --git a/client/gui_rpc_server.C b/client/gui_rpc_server.C index c3138333f3..5f55270169 100644 --- a/client/gui_rpc_server.C +++ b/client/gui_rpc_server.C @@ -39,6 +39,10 @@ #include "client_msgs.h" #include "client_state.h" +using std::string; +using std::list; +using std::vector; + GUI_RPC_CONN::GUI_RPC_CONN(int s) { sock = s; } diff --git a/client/gui_rpc_server.h b/client/gui_rpc_server.h index b1e4e53245..cc0010c808 100644 --- a/client/gui_rpc_server.h +++ b/client/gui_rpc_server.h @@ -27,7 +27,7 @@ public: }; class GUI_RPC_CONN_SET { - vector gui_rpcs; + std::vector gui_rpcs; int insert(GUI_RPC_CONN*); int lsock; public: diff --git a/client/http.C b/client/http.C index a360b30770..a09ed63951 100644 --- a/client/http.C +++ b/client/http.C @@ -22,7 +22,6 @@ #ifdef _WIN32 #include "boinc_win.h" #define SHUT_WR SD_SEND -using std::string; #endif #ifndef _WIN32 @@ -54,6 +53,9 @@ using std::string; #define HTTP_BLOCKSIZE 16384 +using std::string; +using std::istringstream; +using std::vector; // Breaks a HTTP url down into its server and file path components // diff --git a/client/http.h b/client/http.h index 1bcf7e29a4..07334fd6eb 100644 --- a/client/http.h +++ b/client/http.h @@ -37,8 +37,8 @@ struct HTTP_REPLY_HEADER { int http_status; int content_length; - string redirect_location; - string recv_buf; + std::string redirect_location; + std::string recv_buf; void init(); int read_reply(int socket); @@ -90,7 +90,7 @@ public: // represents a set of HTTP requests in progress // class HTTP_OP_SET { - vector http_ops; + std::vector http_ops; NET_XFER_SET* net_xfers; public: HTTP_OP_SET(NET_XFER_SET*); diff --git a/client/net_xfer.C b/client/net_xfer.C index 970c75a39c..89de50c05f 100644 --- a/client/net_xfer.C +++ b/client/net_xfer.C @@ -86,6 +86,8 @@ typedef size_t socklen_t; #endif #endif +using std::vector; + // if an active transfer doesn't get any activity // in this many seconds, error out #define NET_XFER_TIMEOUT 600 diff --git a/client/net_xfer.h b/client/net_xfer.h index 4a5be397a6..c7a445c67f 100644 --- a/client/net_xfer.h +++ b/client/net_xfer.h @@ -81,7 +81,7 @@ public: // Each second we reset these to zero. class NET_XFER_SET { - vector net_xfers; + std::vector net_xfers; public: NET_XFER_SET(); double max_bytes_sec_up, max_bytes_sec_down; diff --git a/client/pers_file_xfer.C b/client/pers_file_xfer.C index a162ff5a8d..da3af60750 100644 --- a/client/pers_file_xfer.C +++ b/client/pers_file_xfer.C @@ -40,6 +40,8 @@ #include "client_types.h" #include "client_msgs.h" +using std::vector; + // PERS_FILE_XFER represents a persistent file transfer. // A set of URLs is given. // diff --git a/client/pers_file_xfer.h b/client/pers_file_xfer.h index 9439fbdb0e..980d772974 100644 --- a/client/pers_file_xfer.h +++ b/client/pers_file_xfer.h @@ -79,7 +79,7 @@ public: class PERS_FILE_XFER_SET { FILE_XFER_SET* file_xfers; public: - vectorpers_file_xfers; + std::vectorpers_file_xfers; PERS_FILE_XFER_SET(FILE_XFER_SET*); int insert(PERS_FILE_XFER*); diff --git a/client/prefs.h b/client/prefs.h index 748683b57e..a4724d091b 100644 --- a/client/prefs.h +++ b/client/prefs.h @@ -55,8 +55,8 @@ struct GLOBAL_PREFS { int max_memory_mbytes; int proc_priority; int cpu_affinity; - string source_project; - string source_scheduler; + std::string source_project; + std::string source_scheduler; GLOBAL_PREFS(); void init(); diff --git a/client/scheduler_op.C b/client/scheduler_op.C index e3727b6503..e2b398a750 100644 --- a/client/scheduler_op.C +++ b/client/scheduler_op.C @@ -39,6 +39,8 @@ #include "log_flags.h" #include "scheduler_op.h" +using std::vector; + extern void project_add_failed(PROJECT*); SCHEDULER_OP::SCHEDULER_OP(HTTP_OP_SET* h) { diff --git a/client/scheduler_op.h b/client/scheduler_op.h index 34e9b2c4d3..d60ed307be 100644 --- a/client/scheduler_op.h +++ b/client/scheduler_op.h @@ -75,12 +75,12 @@ struct SCHEDULER_OP { int init_op_project(double ns); int init_master_fetch(PROJECT*); int set_min_rpc_time(PROJECT*); - bool update_urls(PROJECT& project, vector &urls); + bool update_urls(PROJECT& project, std::vector &urls); int start_op(PROJECT*); bool check_master_fetch_start(); void backoff(PROJECT* p, char *error_msg); int start_rpc(); - int parse_master_file(vector&); + int parse_master_file(std::vector&); }; struct SCHEDULER_REPLY { @@ -103,12 +103,12 @@ struct SCHEDULER_REPLY { double user_expavg_credit; char host_venue[256]; unsigned int user_create_time; - vector apps; - vector file_infos; - vector app_versions; - vector workunits; - vector results; - vector result_acks; + std::vector apps; + std::vector file_infos; + std::vector app_versions; + std::vector workunits; + std::vector results; + std::vector result_acks; char* code_sign_key; char* code_sign_key_signature; bool trickle_up_ack; diff --git a/db/db_base.C b/db/db_base.C index 8229bbe5d1..ba9ce3b222 100644 --- a/db/db_base.C +++ b/db/db_base.C @@ -108,7 +108,7 @@ int DB_BASE::lookup(char* clause) { MYSQL_ROW row; MYSQL_RES* rp; - if (mysql && is_high_priority) { + if (db->mysql && db->is_high_priority) { sprintf(query, "select HIGH_PRIORITY * from %s %s", table_name, clause); } else { sprintf(query, "select * from %s %s", table_name, clause); @@ -136,7 +136,7 @@ int DB_BASE::lookup_id(int id) { MYSQL_ROW row; MYSQL_RES* rp; - if (mysql && is_high_priority) { + if (db->mysql && db->is_high_priority) { sprintf(query, "select HIGH_PRIORITY * from %s where id=%d", table_name, id); } else { sprintf(query, "select * from %s where id=%d", table_name, id); @@ -163,7 +163,7 @@ int DB_BASE::enumerate(char* clause) { if (!cursor.active) { cursor.active = true; - if (mysql && is_high_priority) { + if (db->mysql && db->is_high_priority) { sprintf(query, "select HIGH_PRIORITY * from %s %s", table_name, clause); } else { sprintf(query, "select * from %s %s", table_name, clause); @@ -232,7 +232,7 @@ int DB_BASE::get_double(char* query, double& x) { int DB_BASE::count(int& n, char* clause) { char query[MAX_QUERY_LEN]; - if (mysql && is_high_priority) { + if (db->mysql && db->is_high_priority) { sprintf(query, "select HIGH_PRIORITY count(*) from %s %s", table_name, clause); } else { sprintf(query, "select count(*) from %s %s", table_name, clause); @@ -244,7 +244,7 @@ int DB_BASE::count(int& n, char* clause) { int DB_BASE::sum(double& x, char* field, char* clause) { char query[MAX_QUERY_LEN]; - if (mysql && is_high_priority) { + if (db->mysql && db->is_high_priority) { sprintf(query, "select HIGH_PRIORITY sum(%s) from %s %s", field, table_name, clause); } else { sprintf(query, "select sum(%s) from %s %s", field, table_name, clause); diff --git a/db/db_base.h b/db/db_base.h index 59e1698106..569e04673b 100644 --- a/db/db_base.h +++ b/db/db_base.h @@ -38,6 +38,7 @@ public: int insert_id(); void print_error(char*); const char* error_string(); + bool is_high_priority; MYSQL* mysql; }; @@ -59,7 +60,6 @@ public: int sum(double&, char* field, char* clause=""); int get_double(char* query, double&); int get_integer(char* query, int&); - bool is_high_priority; DB_CONN* db; const char *table_name; diff --git a/lib/app_ipc.C b/lib/app_ipc.C index 23873c0d1a..e4eee9fbe1 100755 --- a/lib/app_ipc.C +++ b/lib/app_ipc.C @@ -34,6 +34,8 @@ #include "app_ipc.h" +using std::string; + char* xml_graphics_modes[NGRAPHICS_MODES] = { "", "", diff --git a/lib/base64.C b/lib/base64.C index 5db4bfc201..8cfb7d6d5f 100644 --- a/lib/base64.C +++ b/lib/base64.C @@ -23,6 +23,8 @@ #include "base64.h" +using std::string; + // Table of characters coding the 64 values. static char base64_value_to_char[64] = { diff --git a/lib/base64.h b/lib/base64.h index 29b65d205b..91b40148a7 100644 --- a/lib/base64.h +++ b/lib/base64.h @@ -24,16 +24,15 @@ #include #include #include -using namespace std; #endif class InvalidBase64Exception { }; -string r_base64_encode (const char* from, size_t length); -string r_base64_decode (const char* from, size_t length); -inline string r_base64_decode (string const& from) +std::string r_base64_encode (const char* from, size_t length); + std::string r_base64_decode (const char* from, size_t length); +inline std::string r_base64_decode (std::string const& from) { return r_base64_decode(from.c_str(), from.length()); } diff --git a/lib/boinc_win.h b/lib/boinc_win.h index 7597e4afc8..d7a527310d 100644 --- a/lib/boinc_win.h +++ b/lib/boinc_win.h @@ -111,8 +111,6 @@ #include -using namespace std; - #define vsnprintf _vsnprintf #define snprintf _snprintf #define fdopen _fdopen @@ -161,4 +159,4 @@ using namespace std; #endif -#endif //_BOINC_WIN_ \ No newline at end of file +#endif //_BOINC_WIN_ diff --git a/lib/exception.h b/lib/exception.h index 2d3c82579f..bbe6e6eaab 100644 --- a/lib/exception.h +++ b/lib/exception.h @@ -22,8 +22,6 @@ #ifndef _WIN32 #include -using namespace std; -using std::exception; #endif #include @@ -31,7 +29,7 @@ using std::exception; // BOINC Base Exception Class // -class boinc_base_exception : public exception +class boinc_base_exception : public std::exception { private: @@ -39,15 +37,15 @@ private: // datatype is 64bits plus the // possible sign character and the // NULL terminator - string m_strErrorBuffer; // the formatted error message when + std::string m_strErrorBuffer; // the formatted error message when // asked - string m_strErrorType; // the error type + std::string m_strErrorType; // the error type long m_lErrorValue; // the error value - string m_strErrorMessage; // the error message - string m_strErrorData; // any relevant data associated with + std::string m_strErrorMessage; // the error message + std::string m_strErrorData; // any relevant data associated with // the error - string m_strFilename; // the file in which the error occurred + std::string m_strFilename; // the file in which the error occurred long m_lLineNumber; // the line number in which the error // occurred diff --git a/lib/filesys.C b/lib/filesys.C index e205d1bd85..e5cedcc36b 100755 --- a/lib/filesys.C +++ b/lib/filesys.C @@ -73,6 +73,8 @@ typedef BOOL (CALLBACK* FreeFn)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULAR #include "fcgi_stdio.h" #endif +using std::string; + char boinc_failed_file[256]; // routines for enumerating the entries in a directory diff --git a/lib/filesys.h b/lib/filesys.h index 9adc90fe9a..d228bba333 100755 --- a/lib/filesys.h +++ b/lib/filesys.h @@ -40,7 +40,6 @@ typedef DIR_DESC *DIRREF; #include #include -using std::string; #ifdef HAVE_DIRENT_H #include @@ -57,7 +56,7 @@ typedef DIR *DIRREF; // extern DIRREF dir_open(const char*); extern int dir_scan(char*, DIRREF, int); -int dir_scan(string&, DIRREF); +int dir_scan(std::string&, DIRREF); extern void dir_close(DIRREF); extern int boinc_delete_file(const char*); @@ -78,7 +77,7 @@ extern char boinc_failed_file[256]; class DirScanner { #ifdef _WIN32 - string dir; + std::string dir; bool first; void* handle; #endif @@ -86,9 +85,9 @@ class DirScanner { DIR* dirp; #endif public: - DirScanner(string const& path); + DirScanner(std::string const& path); ~DirScanner(); - bool scan(string& name); // return true if file returned + bool scan(std::string& name); // return true if file returned }; #endif diff --git a/lib/miofile.h b/lib/miofile.h index cd6c6187ed..ad2fa2fb65 100644 --- a/lib/miofile.h +++ b/lib/miofile.h @@ -22,7 +22,6 @@ #ifndef _WIN32 #include -using namespace std; #endif #include "mfile.h" @@ -58,6 +57,6 @@ private: }; extern int copy_element_contents(MIOFILE& in, const char* end_tag, char* p, int len); -extern int copy_element_contents(MIOFILE& in, const char* end_tag, string&); +extern int copy_element_contents(MIOFILE& in, const char* end_tag, std::string&); #endif diff --git a/lib/parse.h b/lib/parse.h index a61da2941a..c544be8276 100644 --- a/lib/parse.h +++ b/lib/parse.h @@ -24,14 +24,13 @@ #include #include #include -using namespace std; #endif extern bool parse(char* , char* ); extern bool parse_int(const char* buf, const char*tag, int&); extern bool parse_double(const char*, const char*, double&); extern bool parse_str(const char*, const char*, char*, int); -extern bool parse_str(const char* buf, const char* tag, string& dest); +extern bool parse_str(const char* buf, const char* tag, std::string& dest); extern void parse_attr(const char* buf, const char* attrname, char* out, int len); extern bool match_tag(const char*, const char*); extern bool match_tag(const std::string &, const char*); @@ -39,12 +38,12 @@ extern void copy_stream(FILE* in, FILE* out); extern void strcatdup(char*& p, char* buf); extern int dup_element_contents(FILE* in, const char* end_tag, char** pp); extern int copy_element_contents(FILE* in, const char* end_tag, char* p, int len); -extern int copy_element_contents(FILE* in, const char* end_tag, string&); +extern int copy_element_contents(FILE* in, const char* end_tag, std::string&); extern int read_file_malloc(const char* pathname, char*& str); extern void replace_element(char* buf, char* start, char* end, char* replacement); extern char* sgets(char* buf, int len, char* &in); -extern void xml_escape(string&, string&); -extern void xml_unescape(string&, string&); +extern void xml_escape(std::string&, std::string&); +extern void xml_unescape(std::string&, std::string&); extern void extract_venue(char*, char*, char*); #endif diff --git a/lib/util.h b/lib/util.h index 40e8bf554c..b73255d54f 100755 --- a/lib/util.h +++ b/lib/util.h @@ -28,7 +28,6 @@ #include #include #include -using namespace std; #endif #if !defined(HAVE_STRLCPY) @@ -47,7 +46,7 @@ extern int parse_command_line( char *, char ** ); extern int lock_file(char*); extern void c2x(char *what); extern void strip_whitespace(char *str); -extern void strip_whitespace(string&); +extern void strip_whitespace(std::string&); extern void unescape_url(char *url); extern void escape_url(char *in, char*out); extern void escape_url_readable(char* in, char* out); @@ -56,27 +55,27 @@ extern void safe_strncpy(char*, const char*, int); #define safe_strcpy(x, y) safe_strncpy(x, y, sizeof(x)) #define safe_strcat(x, y) if (strlen(x)+strlen(y)=suffix.size() && s.substr(s.size()-suffix.size()) == suffix; } -inline bool starts_with(string const& s, string const& prefix) { +inline bool starts_with(std::string const& s, std::string const& prefix) { return s.substr(0, prefix.size()) == prefix; } // http://lists.debian.org/debian-gcc/2002/debian-gcc-200204/msg00092.html inline void downcase_string( - string::iterator begin, string::iterator end, string::iterator src + std::string::iterator begin, std::string::iterator end, std::string::iterator src ) { std::transform(begin, end, src, (int(*)(int))tolower); } -inline void downcase_string(string& w) { +inline void downcase_string(std::string& w) { downcase_string(w.begin(), w.end(), w.begin()); } diff --git a/sched/assimilate_handler.C b/sched/assimilate_handler.C index 02a643ce18..e8f9c83669 100644 --- a/sched/assimilate_handler.C +++ b/sched/assimilate_handler.C @@ -5,6 +5,8 @@ #include "sched_util.h" #include "assimilate_handler.h" +using std::vector; + void assimilate_handler( WORKUNIT& wu, vector& results, RESULT& canonical_result ) { diff --git a/sched/assimilate_handler.h b/sched/assimilate_handler.h index 262e834356..27f36d2543 100644 --- a/sched/assimilate_handler.h +++ b/sched/assimilate_handler.h @@ -1,5 +1,4 @@ #include #include "boinc_db.h" -using namespace std; -extern void assimilate_handler(WORKUNIT&, vector&, RESULT&); +extern void assimilate_handler(WORKUNIT&, std::vector&, RESULT&); diff --git a/sched/assimilator.C b/sched/assimilator.C index 34f3cebaac..e465dfa22c 100644 --- a/sched/assimilator.C +++ b/sched/assimilator.C @@ -34,6 +34,8 @@ #include "sched_msgs.h" #include "assimilate_handler.h" +using std::vector; + #define LOCKFILE "assimilator.out" #define PIDFILE "assimilator.pid" diff --git a/sched/db_dump.C b/sched/db_dump.C index 5126c92f1c..1962ff7172 100644 --- a/sched/db_dump.C +++ b/sched/db_dump.C @@ -59,6 +59,9 @@ #include "sched_util.h" #include "sched_msgs.h" +using std::string; +using std::vector; + #define LOCKFILE "db_dump.out" #define COMPRESSION_NONE 0 diff --git a/sched/transitioner.C b/sched/transitioner.C index 4c7d0538ab..17ced8841a 100644 --- a/sched/transitioner.C +++ b/sched/transitioner.C @@ -71,7 +71,7 @@ void handle_wu(DB_WORKUNIT& wu) { // set the query priority to high so the transitioner can move through // even high loads // - result.is_high_priority = true; + result.db->is_high_priority = true; sprintf(buf, "where workunitid=%d", wu.id); while (!result.enumerate(buf)) { @@ -368,7 +368,7 @@ bool do_pass() { // set the query priority to high so the transitioner can move through // even high loads // - wu.is_high_priority = true; + wu.db->is_high_priority = true; // loop over WUs that are due to be checked // diff --git a/sched/validate_test.C b/sched/validate_test.C index a5ef4d245d..3d41e12666 100644 --- a/sched/validate_test.C +++ b/sched/validate_test.C @@ -22,11 +22,14 @@ #include "sched_msgs.h" #include "validate_util.h" +using std::string; +using std::vector; + // TODO: use md5 hash // read file into memory // -int init_result_read_file(RESULT const& result, void*& data) { +int init_result_read_file(RESULT const & result, void*& data) { int retval; string path; diff --git a/sched/validate_trivial.C b/sched/validate_trivial.C index 9c435ec223..e6025c11c7 100644 --- a/sched/validate_trivial.C +++ b/sched/validate_trivial.C @@ -22,6 +22,8 @@ #include "validate_util.h" +using std::vector; + static const double MIN_CPU_TIME = 10000; // TODO: use md5 hash diff --git a/sched/validate_util.C b/sched/validate_util.C index dd3d1a0254..f34e8f6e2e 100644 --- a/sched/validate_util.C +++ b/sched/validate_util.C @@ -32,6 +32,9 @@ #include "sched_msgs.h" #include "validate_util.h" +using std::vector; +using std::string; + extern SCHED_CONFIG config; // get the name of a result's (first) output file diff --git a/sched/validate_util.h b/sched/validate_util.h index 366f3e36b2..178acfe74e 100644 --- a/sched/validate_util.h +++ b/sched/validate_util.h @@ -23,17 +23,15 @@ #include "boinc_db.h" #include #include -using std::vector; -using std::string; typedef int (*init_result_f)(RESULT const&, void*&); typedef int (*check_pair_with_data_f)(RESULT const&, void*, RESULT const&, void*, bool&); typedef int (*cleanup_result_f)(RESULT const&, void*); -extern int get_output_file_path(RESULT const& result, string& path); -extern double median_mean_credit(vector const& results); +extern int get_output_file_path(RESULT const& result, std::string& path); +extern double median_mean_credit(std::vector const& results); int generic_check_set_majority( - vector& results, int& canonicalid, double& credit, + std::vector& results, int& canonicalid, double& credit, init_result_f init_result_f, check_pair_with_data_f check_pair_with_data_f, cleanup_result_f cleanup_result_f