@@ -89,22 +89,20 @@ void *queue_function(void * /*arg*/) {
8989
9090static int sim_rtapi_run_threads (int fd, int (*callback)(int fd));
9191
92- using namespace std ;
93-
94- template <class T > T DLSYM (void *handle, const string &name) {
92+ template <class T > T DLSYM (void *handle, const std::string &name) {
9593 return (T)(dlsym (handle, name.c_str ()));
9694}
9795
9896template <class T > T DLSYM (void *handle, const char *name) {
9997 return (T)(dlsym (handle, name));
10098}
10199
102- static std::map<string, void *> modules;
100+ static std::map<std:: string, void *> modules;
103101
104102static int instance_count = 0 ;
105103static int force_exit = 0 ;
106104
107- static int do_newinst_cmd (const string& type, const string& name, const string& arg) {
105+ static int do_newinst_cmd (const std:: string& type, const std:: string& name, const std:: string& arg) {
108106 void *module = modules[" hal_lib" ];
109107 if (!module ) {
110108 rtapi_print_msg (RTAPI_MSG_ERR,
@@ -130,7 +128,7 @@ static int do_newinst_cmd(const string& type, const string& name, const string&
130128 return comp->make ((char *)name.c_str (), (char *)arg.c_str ());
131129}
132130
133- static int do_one_item (char item_type_char, const string ¶m_name, const string ¶m_value, void *vitem, int idx=0 ) {
131+ static int do_one_item (char item_type_char, const std:: string ¶m_name, const std:: string ¶m_value, void *vitem, int idx=0 ) {
134132 char *endp;
135133 switch (item_type_char) {
136134 case ' l' : {
@@ -169,22 +167,22 @@ static int do_one_item(char item_type_char, const string ¶m_name, const stri
169167 return 0 ;
170168}
171169
172- void remove_quotes (string &s) {
170+ void remove_quotes (std:: string &s) {
173171 s.erase (remove_copy (s.begin (), s.end (), s.begin (), ' "' ), s.end ());
174172}
175173
176- static int do_comp_args (void *module , vector<string> args) {
174+ static int do_comp_args (void *module , std:: vector<std:: string> args) {
177175 for (unsigned i=1 ; i < args.size (); i++) {
178- string &s = args[i];
176+ std:: string &s = args[i];
179177 remove_quotes (s);
180178 size_t idx = s.find (' =' );
181- if (idx == string::npos) {
179+ if (idx == std:: string::npos) {
182180 rtapi_print_msg (RTAPI_MSG_ERR, " Invalid parameter `%s'\n " ,
183181 s.c_str ());
184182 return -1 ;
185183 }
186- string param_name (s, 0 , idx);
187- string param_value (s, idx+1 );
184+ std:: string param_name (s, 0 , idx);
185+ std:: string param_value (s, idx+1 );
188186 void *item=DLSYM<void *>(module , " rtapi_info_address_" + param_name);
189187 if (!item) {
190188 rtapi_print_msg (RTAPI_MSG_ERR,
@@ -206,19 +204,19 @@ static int do_comp_args(void *module, vector<string> args) {
206204 int max_size = *max_size_ptr;
207205 size_t idx = 0 ;
208206 int i = 0 ;
209- while (idx != string::npos) {
207+ while (idx != std:: string::npos) {
210208 if (i == max_size) {
211209 rtapi_print_msg (RTAPI_MSG_ERR,
212210 " %s: can only take %d arguments\n " ,
213211 s.c_str (), max_size);
214212 return -1 ;
215213 }
216214 size_t idx1 = param_value.find (" ," , idx);
217- string substr (param_value, idx, idx1 - idx);
215+ std:: string substr (param_value, idx, idx1 - idx);
218216 int result = do_one_item (item_type_char, s, substr, item, i);
219217 if (result != 0 ) return result;
220218 i++;
221- idx = idx1 == string::npos ? idx1 : idx1 + 1 ;
219+ idx = idx1 == std:: string::npos ? idx1 : idx1 + 1 ;
222220 }
223221 } else {
224222 int result = do_one_item (item_type_char, s, param_value, item);
@@ -228,7 +226,7 @@ static int do_comp_args(void *module, vector<string> args) {
228226 return 0 ;
229227}
230228
231- static int do_load_cmd (const string& name, const vector<string>& args) {
229+ static int do_load_cmd (const std:: string& name, const std:: vector<std:: string>& args) {
232230 void *w = modules[name];
233231 if (w == NULL ) {
234232 char what[LINELEN+1 ];
@@ -272,7 +270,7 @@ static int do_load_cmd(const string& name, const vector<string>& args) {
272270 }
273271}
274272
275- static int do_unload_cmd (const string& name) {
273+ static int do_unload_cmd (const std:: string& name) {
276274 void *w = modules[name];
277275 if (w == NULL ) {
278276 rtapi_print_msg (RTAPI_MSG_ERR, " %s: not loaded\n " , name.c_str ());
@@ -287,15 +285,15 @@ static int do_unload_cmd(const string& name) {
287285 return 0 ;
288286}
289287
290- static int do_debug_cmd (const string& value) {
288+ static int do_debug_cmd (const std:: string& value) {
291289 try {
292290 int new_level = stoi (value);
293291 if (new_level < 0 || new_level > 5 ){
294292 rtapi_print_msg (RTAPI_MSG_ERR, " Debug level must be >=0 and <= 5\n " );
295293 return -EINVAL;
296294 }
297295 return rtapi_set_msg_level (new_level);
298- }catch (invalid_argument &e){
296+ }catch (std:: invalid_argument &e){
299297 // stoi will throw an exception if parsing is not possible
300298 rtapi_print_msg (RTAPI_MSG_ERR, " Debug level is not a number\n " );
301299 return -EINVAL;
@@ -318,20 +316,20 @@ static int read_number(int fd) {
318316 }
319317}
320318
321- static string read_string (int fd) {
319+ static std:: string read_string (int fd) {
322320 int len = read_number (fd);
323321 if (len < 0 )
324322 throw ReadError ();
325323 if (!len)
326- return string ();
327- string str (len, 0 );
324+ return std:: string ();
325+ std:: string str (len, 0 );
328326 if (read (fd, str.data (), len) != len)
329327 throw ReadError ();
330328 return str;
331329}
332330
333- static vector<string> read_strings (int fd) {
334- vector<string> result;
331+ static std:: vector<std:: string> read_strings (int fd) {
332+ std:: vector<std:: string> result;
335333 int count = read_number (fd);
336334 if (count < 0 )
337335 return result;
@@ -341,33 +339,33 @@ static vector<string> read_strings(int fd) {
341339 return result;
342340}
343341
344- static void write_number (string &buf, int num) {
342+ static void write_number (std:: string &buf, int num) {
345343 char numbuf[10 ];
346344 snprintf (numbuf, sizeof (numbuf), " %d " , num);
347345 buf = buf + numbuf;
348346}
349347
350- static void write_string (string &buf, const string& s) {
348+ static void write_string (std:: string &buf, const std:: string& s) {
351349 write_number (buf, s.size ());
352350 buf += s;
353351}
354352
355- static void write_strings (int fd, const vector<string>& strings) {
356- string buf;
353+ static void write_strings (int fd, const std:: vector<std:: string>& strings) {
354+ std:: string buf;
357355 write_number (buf, strings.size ());
358356 for (unsigned int i=0 ; i<strings.size (); i++) {
359357 write_string (buf, strings[i]);
360358 }
361359 if (write (fd, buf.data (), buf.size ()) != (ssize_t )buf.size ()) throw WriteError ();
362360}
363361
364- static int handle_command (vector<string> args) {
362+ static int handle_command (std:: vector<std:: string> args) {
365363 if (args.size () == 0 ) { return 0 ; }
366364 if (args.size () == 1 && args[0 ] == " exit" ) {
367365 force_exit = 1 ;
368366 return 0 ;
369367 } else if (args.size () >= 2 && args[0 ] == " load" ) {
370- string name = args[1 ];
368+ std:: string name = args[1 ];
371369 args.erase (args.begin ());
372370 return do_load_cmd (name, args);
373371 } else if (args.size () == 2 && args[0 ] == " unload" ) {
@@ -386,7 +384,7 @@ static int handle_command(vector<string> args) {
386384 }
387385}
388386
389- static int slave (int fd, const vector<string>& args) {
387+ static int slave (int fd, const std:: vector<std:: string>& args) {
390388 try {
391389 write_strings (fd, args);
392390 }
@@ -419,7 +417,7 @@ static int callback(int fd)
419417 close (fd1);
420418 return -1 ;
421419 }
422- string buf;
420+ std:: string buf;
423421 write_number (buf, result);
424422 if (write (fd1, buf.data (), buf.size ()) != (ssize_t )buf.size ()) {
425423 rtapi_print_msg (RTAPI_MSG_ERR,
@@ -432,15 +430,15 @@ static int callback(int fd)
432430
433431static pthread_t main_thread{};
434432
435- static int master (int fd, const vector<string>& args) {
433+ static int master (int fd, const std:: vector<std:: string>& args) {
436434 main_thread = pthread_self ();
437435 int result;
438436 if ((result = pthread_create (&queue_thread, nullptr , &queue_function, nullptr )) != 0 ) {
439437 errno = result;
440438 perror (" pthread_create (queue function)" );
441439 return -1 ;
442440 }
443- do_load_cmd (" hal_lib" , vector<string>());
441+ do_load_cmd (" hal_lib" , std:: vector<std:: string>());
444442 instance_count = 0 ;
445443 App (); // force rtapi_app to be created
446444 if (args.size ()) {
@@ -520,8 +518,8 @@ int main(int argc, char **argv) {
520518#ifdef __linux__
521519 setfsuid (ruid);
522520#endif
523- vector<string> args;
524- for (int i=1 ; i<argc; i++) { args.push_back (string (argv[i])); }
521+ std:: vector<std:: string> args;
522+ for (int i=1 ; i<argc; i++) { args.push_back (std:: string (argv[i])); }
525523
526524become_master:
527525 int len=0 ;
@@ -744,7 +742,7 @@ static int harden_rt()
744742 return 0 ;
745743}
746744
747- static RtapiApp *makeDllApp (string dllName, int policy){
745+ static RtapiApp *makeDllApp (std:: string dllName, int policy){
748746 void *dll = nullptr ;
749747 dll = dlopen (dllName.c_str (), RTLD_NOW);
750748 if (!dll){
@@ -784,7 +782,7 @@ static RtapiApp *makeApp()
784782 }
785783
786784 if (!app){
787- throw invalid_argument (" Could not load rtapi dll" );
785+ throw std:: invalid_argument (" Could not load rtapi dll" );
788786 }else {
789787 return app;
790788 }
0 commit comments