本文整理汇总了C++中Error::GetMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ Error::GetMessage方法的具体用法?C++ Error::GetMessage怎么用?C++ Error::GetMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::GetMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: args
int
main(int argc, char **argv)
{
Args args(argc, argv, "FILE.igc");
const auto path = args.ExpectNextPath();
args.ExpectEnd();
GRecord g;
g.Initialize();
Error error;
if (!g.LoadFileToBuffer(path, error)) {
fprintf(stderr, "%s\n", error.GetMessage());
return 2;
}
g.FinalizeBuffer();
if (!g.AppendGRecordToFile(path)) {
fprintf(stderr, "Failed to write file\n");
return 2;
}
return 0;
}
示例2: args
int
main(int argc, char **argv)
{
Args args(argc, argv, "PATH");
const auto path = args.ExpectNextPath();
args.ExpectEnd();
Error error;
FileLineReaderA reader(path, error);
if (reader.error()) {
fprintf(stderr, "%s\n", error.GetMessage());
return EXIT_FAILURE;
}
FileRepository repository;
if (!ParseFileRepository(repository, reader)) {
fprintf(stderr, "Failed to parse file\n");
return EXIT_FAILURE;
}
for (auto i = repository.begin(), end = repository.end(); i != end; ++i) {
const auto &file = *i;
printf("file '%s' '%s' area='%s' type=%u\n",
file.GetName(), file.GetURI(), file.GetArea(),
(unsigned)file.type);
}
return EXIT_SUCCESS;
}
示例3: main
int main(int argc, char **argv)
{
Args args(argc, argv, "PATH");
const char *path = args.ExpectNext();
args.ExpectEnd();
ZZIP_DIR *dir = zzip_dir_open(path, NULL);
if (dir == NULL) {
fprintf(stderr, "Failed to open %s\n", (const char *)path);
return EXIT_FAILURE;
}
Error error;
ZipLineReaderA reader(dir, "topology.tpl", error);
if (reader.error()) {
fprintf(stderr, "%s\n", error.GetMessage());
return EXIT_FAILURE;
}
TopographyStore topography;
NullOperationEnvironment operation;
topography.Load(operation, reader, NULL, dir);
zzip_dir_close(dir);
topography.LoadAll();
#ifdef ENABLE_OPENGL
TriangulateAll(topography);
#endif
return EXIT_SUCCESS;
}
示例4: reader
void
IGCFileVisitor::Visit(Path path, Path filename)
{
Error error;
FileLineReaderA reader(path, error);
if (reader.error()) {
fprintf(stderr, "%s\n", error.GetMessage());
return;
}
IGCExtensions extensions;
extensions.clear();
FlightCheck flight(filename.c_str());
char *line;
while ((line = reader.ReadLine()) != NULL) {
unsigned day, month, year;
IGCFix fix;
if (IGCParseFix(line, extensions, fix))
flight.fix(fix);
else if (sscanf(line, "HFDTE%02u%02u%02u", &day, &month, &year)) {
/* damn you, Y2K bug! */
if (year > 80)
year += 1900;
else
year += 2000;
flight.date(year, month, day);
}
}
flight.finish();
}
示例5: reader
static void
TestWriter()
{
Profile::Clear();
Profile::Set("key1", 4);
Profile::Set("key2", "value2");
Profile::SaveFile(Path(_T("output/TestProfileWriter.prf")));
Error error;
FileLineReader reader(Path(_T("output/TestProfileWriter.prf")), error);
if (reader.error()) {
skip(3, 0, error.GetMessage());
return;
}
unsigned count = 0;
bool found1 = false, found2 = false;
TCHAR *line;
while ((line = reader.ReadLine()) != NULL) {
if (StringIsEqual(line, _T("key1=\"4\"")))
found1 = true;
if (StringIsEqual(line, _T("key2=\"value2\"")))
found2 = true;
count++;
}
ok1(count == 2);
ok1(found1);
ok1(found2);
}
示例6: args
int
main(int argc, char **argv)
{
Args args(argc, argv, "FILE.igc");
const auto path = args.ExpectNextPath();
args.ExpectEnd();
{
GRecord grecord;
grecord.Initialize();
Error error;
if (!grecord.VerifyGRecordInFile(path, error)) {
fprintf(stderr, "%s\n", error.GetMessage());
return EXIT_FAILURE;
}
}
printf("Valid G record found\n");
FileTransaction transaction(path);
{
Error error;
FileLineReaderA reader(path, error);
if (reader.error()) {
fprintf(stderr, "%s\n", error.GetMessage());
return EXIT_FAILURE;
}
if (!FixGRecord(reader, transaction.GetTemporaryPath())) {
fprintf(stderr, "Failed to write output file\n");
return EXIT_FAILURE;
}
}
if (!transaction.Commit()) {
fprintf(stderr, "Failed to commit output file\n");
return EXIT_FAILURE;
}
printf("New G record written\n");
return EXIT_SUCCESS;
}
示例7: main
int main(int argc, char **argv)
{
Args args(argc, argv, "FILE");
const auto path = args.ExpectNextPath();
args.ExpectEnd();
Error error;
FileLineReaderA reader(path, error);
if (reader.error()) {
fprintf(stderr, "%s\n", error.GetMessage());
return EXIT_FAILURE;
}
KalmanFilter1d kalman_filter(0.0075);
unsigned last_t = 0;
double last_value;
const char *line;
while ((line = reader.ReadLine()) != nullptr) {
const char *p = line;
char *endptr;
unsigned t = strtoul(p, &endptr, 10);
if (endptr == line) {
fprintf(stderr, "Malformed line: %s\n", line);
return EXIT_FAILURE;
}
p = endptr;
double value = strtod(p, &endptr);
if (endptr == line) {
fprintf(stderr, "Malformed line: %s\n", line);
return EXIT_FAILURE;
}
if (last_t > 0 && t > last_t) {
auto dt = (t - last_t) / 1000.;
kalman_filter.Update(value, 0.05, dt);
printf("%u %f %f %f %f\n", t,
value, (value - last_value) / dt,
kalman_filter.GetXAbs(), kalman_filter.GetXVel());
}
last_t = t;
last_value = value;
}
return EXIT_SUCCESS;
}
示例8: DebugReplayNMEA
DebugReplay*
DebugReplayNMEA::Create(Path input_file, const tstring &driver_name)
{
const struct DeviceRegister *driver = FindDriverByName(driver_name.c_str());
if (driver == NULL) {
_ftprintf(stderr, _T("No such driver: %s\n"), driver_name.c_str());
return nullptr;
}
Error error;
FileLineReaderA *reader = new FileLineReaderA(input_file, error);
if (reader->error()) {
delete reader;
fprintf(stderr, "%s\n", error.GetMessage());
return nullptr;
}
return new DebugReplayNMEA(reader, driver);
}
示例9: reader
static bool
ParseFile(Path path, Airspaces &airspaces)
{
Error error;
FileLineReader reader(path, error, Charset::AUTO);
if (!ok1(!reader.error())) {
skip(1, 0, error.GetMessage());
return false;
}
AirspaceParser parser(airspaces);
NullOperationEnvironment operation;
if (!ok1(parser.Parse(reader, operation)))
return false;
airspaces.Optimise();
return true;
}
示例10: main
int main(int argc, char **argv)
{
Args args(argc, argv, "FILE.lua");
const auto path = args.ExpectNextPath();
args.ExpectEnd();
int result = EXIT_SUCCESS;
lua_State *L = Lua::NewBasicState();
Lua::InitLog(L);
lua_register(L, "alert", l_alert);
Error error;
if (!Lua::RunFile(L, path, error)) {
fprintf(stderr, "%s\n", error.GetMessage());
result = EXIT_FAILURE;
}
lua_close(L);
return result;
}
示例11: reader
static bool
TestTrace(const char *filename, unsigned ntrace, bool output=false)
{
Error error;
FileLineReaderA reader(filename, error);
if (reader.error()) {
fprintf(stderr, "%s\n", error.GetMessage());
return false;
}
printf("# %d", ntrace);
Trace trace(1000, ntrace);
IGCExtensions extensions;
extensions.clear();
char *line;
int i = 0;
for (; (line = reader.ReadLine()) != NULL; i++) {
if (output && (i % 500 == 0)) {
putchar('.');
fflush(stdout);
}
IGCFix fix;
if (!IGCParseFix(line, extensions, fix) || !fix.gps_valid)
continue;
OnAdvance(trace,
fix.location,
fixed(fix.gps_altitude),
fixed(fix.time.GetSecondOfDay()));
}
putchar('\n');
printf("# samples %d\n", i);
return true;
}
示例12: f
static bool
test_replay()
{
Directory::Create(Path(_T("output/results")));
std::ofstream f("output/results/res-sample.txt");
GlidePolar glide_polar(4.0);
Waypoints waypoints;
AircraftState state_last;
TaskBehaviour task_behaviour;
task_behaviour.SetDefaults();
task_behaviour.auto_mc = true;
TaskManager task_manager(task_behaviour, waypoints);
TaskEventsPrint default_events(verbose);
task_manager.SetTaskEvents(default_events);
glide_polar.SetBallast(1.0);
task_manager.SetGlidePolar(glide_polar);
OrderedTask* t = task_load(task_behaviour);
if (t) {
task_manager.Commit(*t);
delete t;
task_manager.Resume();
} else {
return false;
}
// task_manager.get_task_advance().get_advance_state() = TaskAdvance::AUTO;
Error error;
FileLineReaderA *reader = new FileLineReaderA(replay_file, error);
if (reader->error()) {
delete reader;
fprintf(stderr, "%s\n", error.GetMessage());
return false;
}
ReplayLoggerSim sim(reader);
sim.state.netto_vario = 0;
bool do_print = verbose;
unsigned print_counter=0;
NMEAInfo basic;
basic.Reset();
while (sim.Update(basic) && !sim.started) {
}
state_last = sim.state;
sim.state.wind.norm = 7;
sim.state.wind.bearing = Angle::Degrees(330);
auto time_last = sim.state.time;
// uncomment this to manually go to first tp
// task_manager.incrementActiveTaskPoint(1);
FlyingComputer flying_computer;
flying_computer.Reset();
FlyingState flying_state;
flying_state.Reset();
while (sim.Update(basic)) {
if (sim.state.time>time_last) {
n_samples++;
flying_computer.Compute(glide_polar.GetVTakeoff(),
sim.state, sim.state.time - time_last,
flying_state);
sim.state.flying = flying_state.flying;
task_manager.Update(sim.state, state_last);
task_manager.UpdateIdle(sim.state);
task_manager.UpdateAutoMC(sim.state, 0);
task_manager.SetTaskAdvance().SetArmed(true);
state_last = sim.state;
if (verbose>1) {
sim.print(f);
f.flush();
}
if (do_print) {
PrintHelper::taskmanager_print(task_manager, sim.state);
}
do_print = (++print_counter % output_skip ==0) && verbose;
}
time_last = sim.state.time;
};
if (verbose) {
PrintDistanceCounts();
//.........这里部分代码省略.........
示例13: LogString
void
LogError(const Error &error)
{
LogString(error.GetMessage());
}
示例14: ShowMessageBox
void
ShowError(const Error &error, const TCHAR *caption)
{
ShowMessageBox(UTF8ToWideConverter(error.GetMessage()), caption,
MB_OK|MB_ICONEXCLAMATION);
}
示例15: LogFormat
void
LogError(const char *msg, const Error &error)
{
LogFormat("%s: %s", msg, error.GetMessage());
}