/* * $Id$ * Copyright (C) 2011 gingko - http://gingko.homeip.net/ * * This file is part of Pouchin TV Mod, a free DVB-T viewer. * See http://www.pouchintv.fr/ for updates. * * Pouchin TV Mod is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Pouchin TV Mod is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ // ==================================================================================== #pragma once // ==================================================================================== class CCmdLine { protected: /// Méthode virtuelle appelée par \p ProcessAll virtual bool ProcessArg(tstring & strArg) = 0; virtual void PostProcess() { } public: tstring strCommand; //!< Commande invoquée (argv[0]) vtstring vCmdArgs; //!< Liste des paramètres suivants vtstring::iterator itArgs; vtstring::iterator itEnd; bool bParamError; /// (Ré)initialisation du traitement des paramètres chargés void Reset() { itArgs = vCmdArgs.begin(); itEnd = vCmdArgs.end(); } bool Next(tstring & strArg); tstring Next(); /// Chargement avec les paramètres de la fonction 'wmain' CCmdLine & Load(int argc, LPWSTR argv[]); /// Chargement avec les paramètres de la fonction 'main' CCmdLine & Load(int argc, LPSTR argv[]); /// Chargement avec une ligne de commande WCHAR brute CCmdLine & Load(LPCWSTR pszCmdLine); /// Chargement avec une ligne de commande CHAR brute CCmdLine & Load(LPCSTR pszCmdLine); /** * \brief Traitement de tous les paramètres chargés * * Appel de la méthode virtuelle pure \p ProcessArg pour chaque paramètre, un par un. * Tient compte de la possibilité que cette fonction appelle \p Next en interne pour * acquérir des paramètres en tant qu'argument : dans ce cas, ces paramètres seront sautés. **/ bool ProcessAll(); /// Constructeur par défaut CCmdLine() : bParamError(false) { } /// Constructeur avec les paramètres de la fonction 'wmain' CCmdLine(int argc, LPWSTR argv[]) : bParamError(false) { Load(argc, argv); } /// Constructeur avec les paramètres de la fonction 'main' CCmdLine(int argc, LPSTR argv[]) : bParamError(false) { Load(argc, argv); } /// Constructeur avec une ligne de commande WCHAR brute CCmdLine(LPCWSTR pszCmdLine) : bParamError(false) { Load(pszCmdLine); } /// Constructeur avec une ligne de commande CHAR brute CCmdLine(LPCSTR pszCmdLine) : bParamError(false) { Load(pszCmdLine); } }; // ====================================================================================