本文整理汇总了C++中CAppParamParser类的典型用法代码示例。如果您正苦于以下问题:C++ CAppParamParser类的具体用法?C++ CAppParamParser怎么用?C++ CAppParamParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAppParamParser类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
// set up some xbmc specific relationships
XBMC::Context context;
#if defined(_DEBUG)
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rlim) == -1)
CLog::Log(LOGDEBUG, "Failed to set core size limit (%s)", strerror(errno));
#endif
// Set up global SIGINT/SIGTERM handler
struct sigaction signalHandler;
std::memset(&signalHandler, 0, sizeof(signalHandler));
signalHandler.sa_handler = &XBMC_POSIX_HandleSignal;
signalHandler.sa_flags = SA_RESTART;
sigaction(SIGINT, &signalHandler, nullptr);
sigaction(SIGTERM, &signalHandler, nullptr);
setlocale(LC_NUMERIC, "C");
// Initialize before CAppParamParser so it can set the log level
g_advancedSettings.Initialize();
CAppParamParser appParamParser;
appParamParser.Parse(argv, argc);
return XBMC_Run(true, appParamParser);
}
示例2: main
int main(int argc, char* argv[])
{
// set up some xbmc specific relationships
XBMC::Context context;
bool renderGUI = true;
//this can't be set from CAdvancedSettings::Initialize() because it will overwrite
//the loglevel set with the --debug flag
#ifdef _DEBUG
g_advancedSettings.m_logLevel = LOG_LEVEL_DEBUG;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_DEBUG;
#else
g_advancedSettings.m_logLevel = LOG_LEVEL_NORMAL;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_NORMAL;
#endif
CLog::SetLogLevel(g_advancedSettings.m_logLevel);
#ifdef TARGET_POSIX
#if defined(DEBUG)
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rlim) == -1)
CLog::Log(LOGDEBUG, "Failed to set core size limit (%s)", strerror(errno));
#endif
#endif
setlocale(LC_NUMERIC, "C");
g_advancedSettings.Initialize();
CAppParamParser appParamParser;
appParamParser.Parse(const_cast<const char**>(argv), argc);
return XBMC_Run(renderGUI);
}
示例3: RegisterKeyboardHandler
CInputManager::CInputManager(const CAppParamParser ¶ms) :
m_keymapEnvironment(new CKeymapEnvironment),
m_buttonTranslator(new CButtonTranslator),
m_irTranslator(new CIRTranslator),
m_customControllerTranslator(new CCustomControllerTranslator),
m_touchTranslator(new CTouchTranslator),
m_joystickTranslator(new CJoystickMapper),
m_mouseButtonMap(new MOUSE::CMouseWindowingButtonMap),
m_keyboardEasterEgg(new KEYBOARD::CKeyboardEasterEgg)
{
m_buttonTranslator->RegisterMapper("touch", m_touchTranslator.get());
m_buttonTranslator->RegisterMapper("customcontroller", m_customControllerTranslator.get());
m_buttonTranslator->RegisterMapper("joystick", m_joystickTranslator.get());
RegisterKeyboardHandler(m_keyboardEasterEgg.get());
if (!params.RemoteControlName().empty())
SetRemoteControlName(params.RemoteControlName());
if (!params.RemoteControlEnabled())
DisableRemoteControl();
// Register settings
std::set<std::string> settingSet;
settingSet.insert(CSettings::SETTING_INPUT_ENABLEMOUSE);
CServiceBroker::GetSettings().RegisterCallback(this, settingSet);
}
示例4: SetupEnv
void CXBMCApp::run()
{
int status = 0;
SetupEnv();
CJNIIntent startIntent = getIntent();
android_printf("XBMC Started with action: %s\n",startIntent.getAction().c_str());
std::string filenameToPlay = GetFilenameFromIntent(startIntent);
if (!filenameToPlay.empty())
{
int argc = 2;
const char** argv = (const char**) malloc(argc*sizeof(char*));
std::string exe_name("XBMC");
argv[0] = exe_name.c_str();
argv[1] = filenameToPlay.c_str();
CAppParamParser appParamParser;
appParamParser.Parse((const char **)argv, argc);
free(argv);
}
android_printf(" => waiting for a window");
// Hack!
// TODO: Change EGL startup so that we can start headless, then create the
// window once android gives us a surface to play with.
while(!m_window)
usleep(1000);
m_firstrun=false;
android_printf(" => running XBMC_Run...");
try
{
status = XBMC_Run(true);
android_printf(" => XBMC_Run finished with %d", status);
}
catch(...)
{
android_printf("ERROR: Exception caught on main loop. Exiting");
}
// If we are have not been force by Android to exit, notify its finish routine.
// This will cause android to run through its teardown events, it calls:
// onPause(), onLostFocus(), onDestroyWindow(), onStop(), onDestroy().
ANativeActivity_finish(m_activity);
m_exiting=true;
}
示例5: SetupEnv
void CXBMCApp::run()
{
int status = 0;
SetupEnv();
m_initialVolume = GetSystemVolume();
CJNIIntent startIntent = getIntent();
android_printf("XBMC Started with action: %s\n",startIntent.getAction().c_str());
std::string filenameToPlay = GetFilenameFromIntent(startIntent);
if (!filenameToPlay.empty())
{
int argc = 2;
const char** argv = (const char**) malloc(argc*sizeof(char*));
std::string exe_name("XBMC");
argv[0] = exe_name.c_str();
argv[1] = filenameToPlay.c_str();
CAppParamParser appParamParser;
appParamParser.Parse((const char **)argv, argc);
free(argv);
}
m_firstrun=false;
android_printf(" => running XBMC_Run...");
try
{
status = XBMC_Run(true);
android_printf(" => XBMC_Run finished with %d", status);
}
catch(...)
{
android_printf("ERROR: Exception caught on main loop. Exiting");
}
// If we are have not been force by Android to exit, notify its finish routine.
// This will cause android to run through its teardown events, it calls:
// onPause(), onLostFocus(), onDestroyWindow(), onStop(), onDestroy().
ANativeActivity_finish(m_activity);
m_exiting=true;
}
示例6: main
int main(int argc, char* argv[])
{
// set up some xbmc specific relationships
XBMC::Context context;
bool renderGUI = true;
//this can't be set from CAdvancedSettings::Initialize() because it will overwrite
//the loglevel set with the --debug flag
#ifdef _DEBUG
g_advancedSettings.m_logLevel = LOG_LEVEL_DEBUG;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_DEBUG;
#else
g_advancedSettings.m_logLevel = LOG_LEVEL_NORMAL;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_NORMAL;
#endif
CLog::SetLogLevel(g_advancedSettings.m_logLevel);
#ifdef _LINUX
#if defined(DEBUG)
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rlim) == -1)
CLog::Log(LOGDEBUG, "Failed to set core size limit (%s)", strerror(errno));
#endif
// Prevent child processes from becoming zombies on exit if not waited upon. See also Util::Command
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_flags = SA_NOCLDWAIT;
sa.sa_handler = SIG_IGN;
sigaction(SIGCHLD, &sa, NULL);
#endif
setlocale(LC_NUMERIC, "C");
g_advancedSettings.Initialize();
#ifndef _WIN32
CAppParamParser appParamParser;
appParamParser.Parse((const char **)argv, argc);
#endif
return XBMC_Run(renderGUI);
}
示例7: RegisterKeyboardHandler
CInputManager::CInputManager(const CAppParamParser ¶ms) :
m_keymapEnvironment(new CKeymapEnvironment),
m_buttonTranslator(new CButtonTranslator),
m_irTranslator(new CIRTranslator),
m_customControllerTranslator(new CCustomControllerTranslator),
m_touchTranslator(new CTouchTranslator),
m_joystickTranslator(new CJoystickMapper),
m_mouseButtonMap(new MOUSE::CMouseWindowingButtonMap),
m_keyboardEasterEgg(new KEYBOARD::CKeyboardEasterEgg)
{
m_buttonTranslator->RegisterMapper("touch", m_touchTranslator.get());
m_buttonTranslator->RegisterMapper("customcontroller", m_customControllerTranslator.get());
m_buttonTranslator->RegisterMapper("joystick", m_joystickTranslator.get());
RegisterKeyboardHandler(m_keyboardEasterEgg.get());
if (!params.RemoteControlName().empty())
SetRemoteControlName(params.RemoteControlName());
if (!params.RemoteControlEnabled())
DisableRemoteControl();
}
示例8: main
int main(int argc, char* argv[])
{
#if defined(_DEBUG)
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rlim) == -1)
CLog::Log(LOGDEBUG, "Failed to set core size limit (%s)", strerror(errno));
#endif
// Set up global SIGINT/SIGTERM handler
struct sigaction signalHandler;
std::memset(&signalHandler, 0, sizeof(signalHandler));
signalHandler.sa_handler = &XBMC_POSIX_HandleSignal;
signalHandler.sa_flags = SA_RESTART;
sigaction(SIGINT, &signalHandler, nullptr);
sigaction(SIGTERM, &signalHandler, nullptr);
setlocale(LC_NUMERIC, "C");
CAppParamParser appParamParser;
appParamParser.Parse(argv, argc);
return XBMC_Run(true, appParamParser);
}
示例9: WinMain
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR commandLine, INT )
{
// set up some xbmc specific relationships
XBMC::Context context;
//this can't be set from CAdvancedSettings::Initialize() because it will overwrite
//the loglevel set with the --debug flag
#ifdef _DEBUG
g_advancedSettings.m_logLevel = LOG_LEVEL_DEBUG;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_DEBUG;
#else
g_advancedSettings.m_logLevel = LOG_LEVEL_NORMAL;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_NORMAL;
#endif
CLog::SetLogLevel(g_advancedSettings.m_logLevel);
// Initializes CreateMiniDump to handle exceptions.
win32_exception::set_version(g_infoManager.GetVersion());
SetUnhandledExceptionFilter( CreateMiniDump );
// check if XBMC is already running
CreateMutex(NULL, FALSE, "XBMC Media Center");
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
HWND m_hwnd = FindWindow("XBMC","XBMC");
if(m_hwnd != NULL)
{
// switch to the running instance
ShowWindow(m_hwnd,SW_RESTORE);
SetForegroundWindow(m_hwnd);
}
return 0;
}
#ifndef HAS_DX
if(CWIN32Util::GetDesktopColorDepth() < 32)
{
//FIXME: replace it by a SDL window for all ports
MessageBox(NULL, "Desktop Color Depth isn't 32Bit", "XBMC: Fatal Error", MB_OK|MB_ICONERROR);
return 0;
}
#endif
//Initialize COM
CoInitializeEx(NULL, COINIT_MULTITHREADED);
// Handle numeric values using the default/POSIX standard
setlocale(LC_NUMERIC, "C");
// If the command line passed to WinMain, commandLine, is not "" we need
// to process the command line arguments.
// Note that commandLine does not include the program name and can be
// equal to "" if no arguments were supplied. By contrast GetCommandLineW()
// does include the program name and is never equal to "".
g_advancedSettings.Initialize();
if (strlen(commandLine) != 0)
{
int argc;
LPWSTR* argvW = CommandLineToArgvW(GetCommandLineW(), &argc);
CStdString* strargvA = new CStdString[argc];
const char** argv = (const char**) LocalAlloc(LMEM_FIXED, argc*sizeof(char*));
for (int i = 0; i < argc; i++)
{
g_charsetConverter.wToUTF8(argvW[i], strargvA[i]);
argv[i] = strargvA[i].c_str();
}
// Parse the arguments
CAppParamParser appParamParser;
appParamParser.Parse(argv, argc);
// Clean up the storage we've used
LocalFree(argvW);
LocalFree(argv);
delete [] strargvA;
}
// Initialise Winsock
WSADATA wd;
WSAStartup(MAKEWORD(2,2), &wd);
// use 1 ms timer precision - like SDL initialization used to do
timeBeginPeriod(1);
// Create and run the app
if(!g_application.Create())
{
CStdString errorMsg;
errorMsg.Format("CApplication::Create() failed - check log file and that it is writable");
MessageBox(NULL, errorMsg.c_str(), "XBMC: Error", MB_OK|MB_ICONERROR);
return 0;
}
#ifndef _DEBUG
// we don't want to see the "no disc in drive" windows message box
//.........这里部分代码省略.........
示例10: WinMain
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR commandLine, INT )
{
// set up some xbmc specific relationships
XBMC::Context context;
//this can't be set from CAdvancedSettings::Initialize() because it will overwrite
//the loglevel set with the --debug flag
#ifdef _DEBUG
g_advancedSettings.m_logLevel = LOG_LEVEL_DEBUG;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_DEBUG;
#else
g_advancedSettings.m_logLevel = LOG_LEVEL_NORMAL;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_NORMAL;
#endif
CLog::SetLogLevel(g_advancedSettings.m_logLevel);
// Initializes CreateMiniDump to handle exceptions.
win32_exception::set_version(g_infoManager.GetVersion());
SetUnhandledExceptionFilter( CreateMiniDump );
// check if Kodi is already running
std::string appName = CSysInfo::GetAppName();
CreateMutex(NULL, FALSE, (appName + " Media Center").c_str());
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
HWND m_hwnd = FindWindow(appName.c_str(), appName.c_str());
if(m_hwnd != NULL)
{
// switch to the running instance
ShowWindow(m_hwnd,SW_RESTORE);
SetForegroundWindow(m_hwnd);
}
return 0;
}
#ifndef HAS_DX
if(CWIN32Util::GetDesktopColorDepth() < 32)
{
//FIXME: replace it by a SDL window for all ports
MessageBox(NULL, "Desktop Color Depth isn't 32Bit", (appName + ": Fatal Error").c_str(), MB_OK|MB_ICONERROR);
return 0;
}
#endif
if((g_cpuInfo.GetCPUFeatures() & CPU_FEATURE_SSE2) == 0)
{
MessageBox(NULL, "No SSE2 support detected", (appName + ": Fatal Error").c_str(), MB_OK|MB_ICONERROR);
return 0;
}
//Initialize COM
CoInitializeEx(NULL, COINIT_MULTITHREADED);
// Handle numeric values using the default/POSIX standard
setlocale(LC_NUMERIC, "C");
// If the command line passed to WinMain, commandLine, is not "" we need
// to process the command line arguments.
// Note that commandLine does not include the program name and can be
// equal to "" if no arguments were supplied. By contrast GetCommandLineW()
// does include the program name and is never equal to "".
g_advancedSettings.Initialize();
if (strlen(commandLine) != 0)
{
int argc;
LPWSTR* argvW = CommandLineToArgvW(GetCommandLineW(), &argc);
std::vector<std::string> strargvA;
strargvA.resize(argc);
const char** argv = (const char**) LocalAlloc(LMEM_FIXED, argc*sizeof(char*));
if (!argv)
return 20;
for (int i = 0; i < argc; i++)
{
g_charsetConverter.wToUTF8(argvW[i], strargvA[i]);
argv[i] = strargvA[i].c_str();
}
// Parse the arguments
CAppParamParser appParamParser;
appParamParser.Parse(argv, argc);
// Clean up the storage we've used
LocalFree(argvW);
LocalFree(argv);
}
// Initialise Winsock
WSADATA wd;
WSAStartup(MAKEWORD(2,2), &wd);
// use 1 ms timer precision - like SDL initialization used to do
timeBeginPeriod(1);
#ifdef XBMC_TRACK_EXCEPTIONS
try
//.........这里部分代码省略.........
示例11: main
int main(int argc, char* argv[])
{
int m_ExitCode;
// set up some xbmc specific relationships
XBMC::Context context;
//this can't be set from CAdvancedSettings::Initialize() because it will overwrite
//the loglevel set with the --debug flag
g_advancedSettings.m_logLevel = LOG_LEVEL_DEBUG;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_DEBUG;
CLog::SetLogLevel(g_advancedSettings.m_logLevel);
#ifdef _LINUX
// Prevent child processes from becoming zombies on exit if not waited upon. See also Util::Command
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_flags = SA_NOCLDWAIT;
sa.sa_handler = SIG_IGN;
sigaction(SIGCHLD, &sa, NULL);
#endif
setlocale(LC_NUMERIC, "C");
g_advancedSettings.Initialize();
#ifndef _WIN32
CAppParamParser appParamParser;
appParamParser.Parse((const char **)argv, argc);
#endif
if (!g_advancedSettings.Initialized())
{
g_advancedSettings.m_logLevel = LOG_LEVEL_DEBUG;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_DEBUG;
g_advancedSettings.Initialize();
}
if (!g_application.Create())
{
fprintf(stderr, "ERROR: Unable to create application. Exiting\n");
return -1;
}
if (!g_application.Initialize())
{
fprintf(stderr, "ERROR: Unable to Initialize. Exiting\n");
return -1;
}
CLog::Log(LOGNOTICE, "Running the application..." );
unsigned int lastFrameTime = 0;
unsigned int frameTime = 0;
const unsigned int noRenderFrameTime = 15; // Simulates ~66fps
CLog::Log(LOGNOTICE, "Starting Video Library Scan..." );
printf("XBMC Media Center %s\n", g_infoManager.GetVersion().c_str());
printf("Copyright (C) 2005-2011 Team XBMC - http://www.xbmc.org\n\n");
printf("Starting Video Library Scan\n\n");
// Start scanning the Video Library for changes...
g_application.StartVideoScan("");
// Run xbmc
while (!g_application.m_bStop)
{
//-----------------------------------------
// Animate and render a frame
//-----------------------------------------
lastFrameTime = XbmcThreads::SystemClockMillis();
g_application.Process();
// Frame move the scene
if (!g_application.m_bStop) g_application.FrameMove(true, false);
// If scanning the Video Library has finished then ask XBMC to quit...
if (!g_application.IsVideoScanning())
{
CApplicationMessenger::Get().Quit();
} else {
printf(".");
frameTime = XbmcThreads::SystemClockMillis() - lastFrameTime;
if(frameTime < noRenderFrameTime)
Sleep(noRenderFrameTime - frameTime);
}
} // while (!m_bStop)
CLog::Log(LOGNOTICE, "Finished Video Library Scan..." );
m_ExitCode = g_application.m_ExitCode;
g_application.Destroy();
printf("\n\nFinished Video Library Scan...\n");
return m_ExitCode;
}
示例12: main
int main(int argc, char* argv[])
{
BYTE processExceptionCount = 0;
const BYTE MAX_EXCEPTION_COUNT = 10;
// set up some xbmc specific relationships
XBMC::Context context;
//this can't be set from CAdvancedSettings::Initialize() because it will overwrite
//the loglevel set with the --debug flag
g_advancedSettings.m_logLevel = LOG_LEVEL_NORMAL;
g_advancedSettings.m_logLevelHint = LOG_LEVEL_NORMAL;
CLog::SetLogLevel(g_advancedSettings.m_logLevel);
CLog::Log(LOGNOTICE, "Starting XBMC Server..." );
printf("XBMC Media Center %s\n", g_infoManager.GetVersion().c_str());
printf("Copyright (C) 2005-2011 Team XBMC - http://www.xbmc.org\n\n");
printf("Starting XBMC Server\n\n");
#ifdef _LINUX
// Prevent child processes from becoming zombies on exit if not waited upon. See also Util::Command
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_flags = SA_NOCLDWAIT;
sa.sa_handler = SIG_IGN;
sigaction(SIGCHLD, &sa, NULL);
#endif
setlocale(LC_NUMERIC, "C");
g_advancedSettings.Initialize();
if (!g_advancedSettings.Initialized())
g_advancedSettings.Initialize();
#ifndef _WIN32
CAppParamParser appParamParser;
appParamParser.Parse((const char **)argv, argc);
#endif
if (!g_application.Create())
{
fprintf(stderr, "ERROR: Unable to create application. Exiting\n");
return -1;
}
if (!g_application.Initialize())
{
fprintf(stderr, "ERROR: Unable to Initialize. Exiting\n");
return -1;
}
// Start scanning the Video Library for changes...
g_application.StartVideoScan("");
// Run xbmc
while (!g_application.m_bStop)
{
//-----------------------------------------
// Animate and render a frame
//-----------------------------------------
try
{
g_application.Process();
//reset exception count
processExceptionCount = 0;
}
catch (...)
{
CLog::Log(LOGERROR, "exception in CApplication::Process()");
processExceptionCount++;
//MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
if (processExceptionCount > MAX_EXCEPTION_COUNT)
{
CLog::Log(LOGERROR, "CApplication::Process(), too many exceptions");
throw;
}
}
// If scanning the Video Library has finished then ask XBMC to quit...
// if (!g_application.IsVideoScanning()) g_application.getApplicationMessenger().Quit();
// Sleep for a little bit so we don't hog the CPU...
Sleep(50);
// printf(".");
} // !g_application.m_bStop
g_application.Destroy();
printf("\n\nExiting XBMC Server...\n");
CLog::Log(LOGNOTICE, "Exiting XBMC Server..." );
return g_application.m_ExitCode;
}