Include standard header files and qualify with std:: where needed.
Qualify various char parameters and variables with const.
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
+#include <cstdlib>
+
#include "dynamicloader.hxx"
FGAirportDynamicsXMLLoader::FGAirportDynamicsXMLLoader(FGAirportDynamics* dyn):
//cout << " " << atts.getName(i) << '=' << atts.getValue(i) << endl;
attname = atts.getName(i);
if (attname == string("index"))
- park.setIndex(atoi(atts.getValue(i)));
+ park.setIndex(std::atoi(atts.getValue(i)));
else if (attname == string("type"))
park.setType(atts.getValue(i));
else if (attname == string("name"))
else if (attname == string("lon"))
park.setLongitude(atts.getValue(i));
else if (attname == string("heading"))
- park.setHeading(atof(atts.getValue(i)));
+ park.setHeading(std::atof(atts.getValue(i)));
else if (attname == string("radius")) {
string radius = atts.getValue(i);
if (radius.find("M") != string::npos)
radius = radius.substr(0, radius.find("M",0));
//cerr << "Radius " << radius <<endl;
- park.setRadius(atof(radius.c_str()));
+ park.setRadius(std::atof(radius.c_str()));
}
else if (attname == string("airlineCodes"))
park.setCodes(atts.getValue(i));
{
attname = atts.getName(i);
if (attname == string("index"))
- taxiNode.setIndex(atoi(atts.getValue(i)));
+ taxiNode.setIndex(std::atoi(atts.getValue(i)));
if (attname == string("lat"))
taxiNode.setLatitude(atts.getValue(i));
if (attname == string("lon"))
taxiNode.setLongitude(atts.getValue(i));
if (attname == string("isOnRunway"))
- taxiNode.setOnRunway((bool) atoi(atts.getValue(i)));
+ taxiNode.setOnRunway((bool) std::atoi(atts.getValue(i)));
if (attname == string("holdPointType")) {
attval = atts.getValue(i);
if (attval==string("none")) {
{
attname = atts.getName(i);
if (attname == string("begin"))
- taxiSegment.setStartNodeRef(atoi(atts.getValue(i)));
+ taxiSegment.setStartNodeRef(std::atoi(atts.getValue(i)));
if (attname == string("end"))
- taxiSegment.setEndNodeRef(atoi(atts.getValue(i)));
+ taxiSegment.setEndNodeRef(std::atoi(atts.getValue(i)));
if (attname == string("isPushBackRoute"))
- taxiSegment.setPushBackType((bool) atoi(atts.getValue(i)));
+ taxiSegment.setPushBackType((bool) std::atoi(atts.getValue(i)));
}
_dynamics->getGroundNetwork()->addSegment(taxiSegment);
}
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
+#include <cstring>
+#include <cstdlib>
+
#include <simgear/debug/logstream.hxx>
#include "runwayprefloader.hxx"
+using namespace std;
+
FGRunwayPreferenceXMLLoader::FGRunwayPreferenceXMLLoader(FGRunwayPreference* p):XMLVisitor(), _pref(p) {}
void FGRunwayPreferenceXMLLoader::startXML () {
# include <config.h>
#endif
-#include <math.h> // fabs()
-#include <stdio.h> // sprintf()
+#include <cmath> // fabs()
+#include <cstdio> // sprintf()
+#include <cstdlib> // atoi()
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#include <cstring>
+
#include "FGfdmSocket.h"
namespace JSBSim {
memset(&scktName, 0, sizeof(struct sockaddr_in));
scktName.sin_family = AF_INET;
scktName.sin_port = htons(port);
- memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
+ std::memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
int len = sizeof(struct sockaddr_in);
if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) { // successful
cout << "Successfully connected to socket for output ..." << endl;
sckt = socket(AF_INET, SOCK_STREAM, 0);
if (sckt >= 0) { // successful
- memset(&scktName, 0, sizeof(struct sockaddr_in));
+ std::memset(&scktName, 0, sizeof(struct sockaddr_in));
scktName.sin_family = AF_INET;
scktName.sin_port = htons(port);
int len = sizeof(struct sockaddr_in);
return _tailIncidence;
}
-char* Airplane::getFailureMsg()
+const char* Airplane::getFailureMsg()
{
return _failureMsg;
}
float getCruiseAoA();
float getTailIncidence();
float getApproachElevator() { return _approachElevator.val; }
- char* getFailureMsg();
+ const char* getFailureMsg();
static void setupState(float aoa, float speed, float gla, State* s); // utility
float _cruiseAoA;
float _tailIncidence;
Control _approachElevator;
- char* _failureMsg;
+ const char* _failureMsg;
};
}; // namespace yasim
return s2;
}
-int FGFDM::attri(XMLAttributes* atts, char* attr)
+int FGFDM::attri(XMLAttributes* atts, const char* attr)
{
if(!atts->hasAttribute(attr)) {
SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << attr <<
return attri(atts, attr, 0);
}
-int FGFDM::attri(XMLAttributes* atts, char* attr, int def)
+int FGFDM::attri(XMLAttributes* atts, const char* attr, int def)
{
const char* val = atts->getValue(attr);
if(val == 0) return def;
else return atol(val);
}
-float FGFDM::attrf(XMLAttributes* atts, char* attr)
+float FGFDM::attrf(XMLAttributes* atts, const char* attr)
{
if(!atts->hasAttribute(attr)) {
SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << attr <<
return attrf(atts, attr, 0);
}
-float FGFDM::attrf(XMLAttributes* atts, char* attr, float def)
+float FGFDM::attrf(XMLAttributes* atts, const char* attr, float def)
{
const char* val = atts->getValue(attr);
if(val == 0) return def;
else return (float)atof(val);
}
-double FGFDM::attrd(XMLAttributes* atts, char* attr)
+double FGFDM::attrd(XMLAttributes* atts, const char* attr)
{
if(!atts->hasAttribute(attr)) {
SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << attr <<
return attrd(atts, attr, 0);
}
-double FGFDM::attrd(XMLAttributes* atts, char* attr, double def)
+double FGFDM::attrd(XMLAttributes* atts, const char* attr, double def)
{
const char* val = atts->getValue(attr);
if(val == 0) return def;
// Unfortunately, this usage creeped into existing configuration files
// while I wasn't active, and it's going to be hard to remove. Issue
// a warning to nag people into changing their ways for now...
-bool FGFDM::attrb(XMLAttributes* atts, char* attr)
+bool FGFDM::attrb(XMLAttributes* atts, const char* attr)
{
const char* val = atts->getValue(attr);
if(val == 0) return false;
bool eq(const char* a, const char* b);
bool caseeq(const char* a, const char* b);
char* dup(const char* s);
- int attri(XMLAttributes* atts, char* attr);
- int attri(XMLAttributes* atts, char* attr, int def);
- float attrf(XMLAttributes* atts, char* attr);
- float attrf(XMLAttributes* atts, char* attr, float def);
- double attrd(XMLAttributes* atts, char* attr);
- double attrd(XMLAttributes* atts, char* attr, double def);
- bool attrb(XMLAttributes* atts, char* attr);
+ int attri(XMLAttributes* atts, const char* attr);
+ int attri(XMLAttributes* atts, const char* attr, int def);
+ float attrf(XMLAttributes* atts, const char* attr);
+ float attrf(XMLAttributes* atts, const char* attr, float def);
+ double attrd(XMLAttributes* atts, const char* attr);
+ double attrd(XMLAttributes* atts, const char* attr, double def);
+ bool attrb(XMLAttributes* atts, const char* attr);
// The core Airplane object we manage.
Airplane _airplane;
#include <stdio.h>
+#include <cstring>
+#include <cstdlib>
+
#include <simgear/props/props.hxx>
#include <simgear/xml/easyxml.hxx>
if(!a->getFailureMsg() && argc > 2 && strcmp(argv[2], "-g") == 0) {
float alt = 5000, kts = 100;
for(int i=3; i<argc; i++) {
- if (strcmp(argv[i], "-a") == 0) alt = atof(argv[++i]);
- else if(strcmp(argv[i], "-s") == 0) kts = atof(argv[++i]);
+ if (std::strcmp(argv[i], "-a") == 0) alt = std::atof(argv[++i]);
+ else if(std::strcmp(argv[i], "-s") == 0) kts = std::atof(argv[++i]);
else return usage();
}
yasim_graph(a, alt, kts);
extern void helpCb(puObject *);
typedef struct {
- char *name;
+ const char *name;
void (*fn)(puObject *);
} __fg_gui_fn_t;
extern const __fg_gui_fn_t __fg_gui_fn[];
// GLOBAL COMMON DIALOG BOX TEXT STRINGS
-extern char *gui_msg_OK; // "OK"
-extern char *gui_msg_NO; // "NO"
-extern char *gui_msg_YES; // "YES"
-extern char *gui_msg_CANCEL; // "CANCEL"
-extern char *gui_msg_RESET; // "RESET"
+extern const char *gui_msg_OK; // "OK"
+extern const char *gui_msg_NO; // "NO"
+extern const char *gui_msg_YES; // "YES"
+extern const char *gui_msg_CANCEL; // "CANCEL"
+extern const char *gui_msg_RESET; // "RESET"
// mouse.cxx
extern void guiInitMouse(int width, int height);
// TODO: remove after the last hardcoded dialog has died
-char *gui_msg_OK = "OK";
-char *gui_msg_NO = "NO";
-char *gui_msg_YES = "YES";
-char *gui_msg_CANCEL = "CANCEL";
-char *gui_msg_RESET = "RESET";
+const char *gui_msg_OK = "OK";
+const char *gui_msg_NO = "NO";
+const char *gui_msg_YES = "YES";
+const char *gui_msg_CANCEL = "CANCEL";
+const char *gui_msg_RESET = "RESET";
const __fg_gui_fn_t __fg_gui_fn[] = {
#include <math.h>
+#include <cstdlib>
+
#include <vector>
SG_USING_STD(vector);
#endif
SG_LOG(SG_GENERAL, SG_INFO, "Exiting FlightGear with status " << status);
- exit(status);
+ std::exit(status);
}
+#include <cstring>
+
#include "UGear_command.hxx"
// cout << sentence << endl;
- len = strlen(sentence);
+ len = std::strlen(sentence);
sum = sentence[0];
for ( i = 1; i < len; i++ ) {
// cout << sentence[i];