cli_parser.hh revision 11821
111821SChristian.Menard@tu-dresden.de/* 211821SChristian.Menard@tu-dresden.de * Copyright (c) 2016, Dresden University of Technology (TU Dresden) 311821SChristian.Menard@tu-dresden.de * All rights reserved. 411821SChristian.Menard@tu-dresden.de * 511821SChristian.Menard@tu-dresden.de * Redistribution and use in source and binary forms, with or without 611821SChristian.Menard@tu-dresden.de * modification, are permitted provided that the following conditions are 711821SChristian.Menard@tu-dresden.de * met: 811821SChristian.Menard@tu-dresden.de * 911821SChristian.Menard@tu-dresden.de * 1. Redistributions of source code must retain the above copyright notice, 1011821SChristian.Menard@tu-dresden.de * this list of conditions and the following disclaimer. 1111821SChristian.Menard@tu-dresden.de * 1211821SChristian.Menard@tu-dresden.de * 2. Redistributions in binary form must reproduce the above copyright 1311821SChristian.Menard@tu-dresden.de * notice, this list of conditions and the following disclaimer in the 1411821SChristian.Menard@tu-dresden.de * documentation and/or other materials provided with the distribution. 1511821SChristian.Menard@tu-dresden.de * 1611821SChristian.Menard@tu-dresden.de * 3. Neither the name of the copyright holder nor the names of its 1711821SChristian.Menard@tu-dresden.de * contributors may be used to endorse or promote products derived from 1811821SChristian.Menard@tu-dresden.de * this software without specific prior written permission. 1911821SChristian.Menard@tu-dresden.de * 2011821SChristian.Menard@tu-dresden.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2111821SChristian.Menard@tu-dresden.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2211821SChristian.Menard@tu-dresden.de * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2311821SChristian.Menard@tu-dresden.de * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 2411821SChristian.Menard@tu-dresden.de * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2511821SChristian.Menard@tu-dresden.de * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2611821SChristian.Menard@tu-dresden.de * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 2711821SChristian.Menard@tu-dresden.de * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 2811821SChristian.Menard@tu-dresden.de * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 2911821SChristian.Menard@tu-dresden.de * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 3011821SChristian.Menard@tu-dresden.de * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3111821SChristian.Menard@tu-dresden.de * 3211821SChristian.Menard@tu-dresden.de * Authors: Christian Menard 3311821SChristian.Menard@tu-dresden.de */ 3411821SChristian.Menard@tu-dresden.de 3511821SChristian.Menard@tu-dresden.de#ifndef __CLI_PARSER_HH__ 3611821SChristian.Menard@tu-dresden.de#define __CLI_PARSER_HH__ 3711821SChristian.Menard@tu-dresden.de 3811821SChristian.Menard@tu-dresden.de#include <cassert> 3911821SChristian.Menard@tu-dresden.de#include <string> 4011821SChristian.Menard@tu-dresden.de#include <vector> 4111821SChristian.Menard@tu-dresden.de 4211821SChristian.Menard@tu-dresden.declass CliParser 4311821SChristian.Menard@tu-dresden.de{ 4411821SChristian.Menard@tu-dresden.de private: 4511821SChristian.Menard@tu-dresden.de int argc; 4611821SChristian.Menard@tu-dresden.de char** argv; 4711821SChristian.Menard@tu-dresden.de 4811821SChristian.Menard@tu-dresden.de bool parsed; 4911821SChristian.Menard@tu-dresden.de 5011821SChristian.Menard@tu-dresden.de uint64_t memoryOffset; 5111821SChristian.Menard@tu-dresden.de uint64_t simulationEnd; 5211821SChristian.Menard@tu-dresden.de bool verboseFlag; 5311821SChristian.Menard@tu-dresden.de std::vector<std::string> debugFlags; 5411821SChristian.Menard@tu-dresden.de std::string configFile; 5511821SChristian.Menard@tu-dresden.de 5611821SChristian.Menard@tu-dresden.de void usage(const std::string& prog_name); 5711821SChristian.Menard@tu-dresden.de public: 5811821SChristian.Menard@tu-dresden.de 5911821SChristian.Menard@tu-dresden.de CliParser() : parsed(false) {} 6011821SChristian.Menard@tu-dresden.de 6111821SChristian.Menard@tu-dresden.de void parse(int argc, char** argv); 6211821SChristian.Menard@tu-dresden.de 6311821SChristian.Menard@tu-dresden.de uint64_t getMemoryOffset() { assert(parsed); return memoryOffset; } 6411821SChristian.Menard@tu-dresden.de uint64_t getSimulationEnd() { assert(parsed); return simulationEnd; } 6511821SChristian.Menard@tu-dresden.de bool getVerboseFlag() { assert(parsed); return verboseFlag; } 6611821SChristian.Menard@tu-dresden.de std::string getConfigFile() { assert(parsed); return configFile; } 6711821SChristian.Menard@tu-dresden.de std::string getDebugFlags(); 6811821SChristian.Menard@tu-dresden.de}; 6911821SChristian.Menard@tu-dresden.de 7011821SChristian.Menard@tu-dresden.de#endif 71