1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
/*
* rtsystem.cpp
*
* Copyright (c) 2000-2004 by Florian Fischer (florianfischer@gmx.de)
* and Martin Trautmann (martintrautmann@gmx.de)
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*/
///// Common System functions ////////////
#include "rtsystem.h"
#include "rtstring.h"
namespace lrt {
String Time::months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
Time Time::operator-(const Time& t)
{
Time ret;
ret.sec = sec - t.sec;
ret.msec = msec - t.msec;
if(ret.msec < 0) {
ret.msec += 1000;
ret.sec--;
}
return ret;
}
int Time::toInt()
{
return sec * 1000 + msec;
}
int Time::getMonthNum(const String& monthName)
{
for(int i = 0; i < 12; i++)
if(monthName == months[i])
return i;
System::println("warning: unrecognized month name: " + monthName);
return 0;
}
////////////////// System ///////////////////
System::BreakFunction System::lastBreakFunction = 0;
void System::exit()
{
System::exit(0);
}
void System::exit(int code, const char* msg)
{
System::exit(code, String(msg));
}
//////////////// Console stuff ///////////
bool System::init = false;
bool System::interactive = true;
String* System::appName = new String("LibRT");
void System::setAppName(const String& appName)
{
delete System::appName;
System::appName = 0;
System::appName = new String(appName);
}
void System::setInteractive(bool val)
{
interactive = val;
}
bool System::isInteractive()
{
return interactive;
}
///////////// Other stuff
bool System::isLittleEndian()
{
short t = 1;
return (((char*)(&t))[0] != 0);
}
int stdCompare(char elem1, char elem2)
{
return int(elem1) - int(elem2);
}
} // namespace
///////////////// System specific stuff //
#ifdef __SYMBIAN32__
#include "rtsystem.epoc.cpp"
#else
#ifdef __WIN32__
#include "rtsystem.win32.cpp"
#else
#include "rtsystem.stdlib.cpp"
#endif
#endif
|