cli.hpp

来自「通信达接口引警 可直接下载股票数据,建立自已的股票软件」· HPP 代码 · 共 62 行

HPP
62
字号

#ifndef _CLI_HPP_
#define _CLI_HPP_

#include <boost/spirit/core.hpp>
#include <iostream>
#include <string>

#include "stock.h"

///////////////////////////////////////////////////////////////////////////////
using namespace std;
using namespace boost::spirit;

#if 0
struct cli_action
{
	template <typename IteratorT>
	void
	operator()( IteratorT first, IteratorT last ) const
	{
		string s( first, last );
		cout << "\tMy Action got: " << s << endl;
	}
};
#endif

///////////////////////////////////////////////////////////////////////////////
//
//  My grammar
//
///////////////////////////////////////////////////////////////////////////////
struct cli_grammar : public grammar<cli_grammar>
{
	template <typename ScannerT>
	struct definition
	{
		definition( cli_grammar const & self )
		{
			node1 = str_p("show");
			node2 = space_p >> str_p("request");
			node3 = str_p("test");
			root = node1 >> node2[&show_curr_bid];
		}

		rule<ScannerT> root;
		rule<ScannerT> node1;
		rule<ScannerT> node2;
		rule<ScannerT> node3;
		rule<ScannerT> node4;

		rule<ScannerT> const &
		start() const
		{
			return root;
		}
	};
};

#endif

⌨️ 快捷键说明

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