⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parsecmd.cpp

📁 BCAM 1394 Driver
💻 CPP
字号:
//-----------------------------------------------------------------------------
//  (c) 2002 by Basler Vision Technologies
//  Section:  Vision Components
//  Project:  BCAM
//  $Header: ParseCmd.cpp, 1, 12.12.2002 16:24:45, Nebelung, H.$
//-----------------------------------------------------------------------------
/**
  \file     ParseCmd.cpp
  \brief    Implementation of simple command line parsing
  
  Code is adopted from "Journal of Object-Oriented Programming March 2001" 
 */
//-----------------------------------------------------------------------------
#include "stdafx.h"
#pragma warning( disable : 4786 )

#include "ParseCmd.h"

using namespace std;

CCmdLineParser::CCmdLineParser(string cmdLine)
{
  m_cmdLine = split(cmdLine);
}

vector<string> CCmdLineParser::split(string& s)
{
  vector<string> ret;
  typedef string::size_type string_size;
  string_size i = 0;

  while (i != s.size())
  {
    // ignore leading blanks
    while (i != s.size() && isspace(s[i]))
      ++i;
    // find end of next word
    string_size j = i;
    while (j != s.size() && !isspace(s[j]))
      ++j;
    // if we found some nonwhitespace characters
    if (i != j)
    {
      // copy from s starting at i and taking j -i chars
      ret.push_back(s.substr(i, j-i));
      i = j;
    }
  }
  return ret;
}

string CCmdLineParser::getArgument(const string& param) const
{
  string ret, temp;
  for (vector<string>::size_type i = 0; i < m_cmdLine.size(); ++i)
  {
    if ( m_cmdLine[i] == param && m_cmdLine.size() > i + 1 )
    {
      temp = m_cmdLine[i+1];
      if ((temp.find("/",0) == -1) && 
             (temp.find("-",0) == -1)) 
        ret = temp;
    }

  }
  return ret;
}

bool CCmdLineParser::isParameter(const string& param) const
{
  for (vector<string>::const_iterator it = m_cmdLine.begin(); it != m_cmdLine.end(); it++)
  {
    if (*it == param)
      return true;
  }
  return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -