当前位置: 首页>>代码示例>>C++>>正文


C++ arguments类代码示例

本文整理汇总了C++中arguments的典型用法代码示例。如果您正苦于以下问题:C++ arguments类的具体用法?C++ arguments怎么用?C++ arguments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了arguments类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: do_append

void binary::do_append(arguments &arg) {
  vector_type &out = v_data;
  for (arguments::iterator it = arg.begin(); it != arg.end(); ++it) {
    value el = *it;
    if (el.is_int()) {
      int x = el.get_int();
      if (x < 0 || x > 255)
        throw exception("Outside byte range", "Range error");
      out.push_back(element_type(x));
    } else if (el.is_object()) {
      object o = el.get_object();
      if (o.is_array()) {
        array a(o);
        std::size_t n = a.length();
        out.reserve(out.size() + n);
        for (std::size_t i = 0; i < n; ++i) {
          value v = a.get_element(i);
          if (!v.is_int())
            throw exception("Must be Array of Numbers");
          int x = v.get_int();
          if (x < 0 || x > 255)
            throw exception("Outside byte range", "RangeError");
          out.push_back(element_type(x));
        }
      } else {
        binary &x = flusspferd::get_native<binary>(o);
        out.insert(out.end(), x.v_data.begin(), x.v_data.end());
      }
    }
  }
}
开发者ID:Flusspferd,项目名称:flusspferd,代码行数:31,代码来源:binary.cpp

示例2: BrdfSlice

		BrdfSlice(const arguments& args,
              int width, int height, int slice,
              double* content)
        : data(brdf_slice_parameters(args),
               width * height * slice),
          _width(width), _height(height), _slice(slice),
          _data(content)
		{
			// Allocate data
      if (args.is_defined("param") && parametrization().dimX() == 3)
          _phi = (M_PI / 180.0) * args.get_float("phi", 90);
      else
          _phi = 0.5*M_PI;

			// Is the position of the slice componnent (third coordinate)
			// reversed? This ensure that some params can be displayed.
      auto in_param = parametrization().input_parametrization();
			_reverse = in_param == params::ISOTROPIC_TL_TV_PROJ_DPHI ||
          in_param == params::SCHLICK_TL_TK_PROJ_DPHI   ||
          in_param == params::RETRO_TL_TVL_PROJ_DPHI;

			// Update the domain
			_max = max();
			_min = min();
		}
开发者ID:belcour,项目名称:alta,代码行数:25,代码来源:slice.cpp

示例3: set_parameters

void rational_fitter_parsec_multi::set_parameters(const arguments& args)
{
    _max_np = args.get_float("np", 10);
    _max_nq = args.get_float("nq", _max_np);
    _min_np = args.get_float("min-np", _max_np);
    _min_nq = args.get_float("min-nq", _min_np);
 
    _max_np = std::max<int>(_max_np, _min_np);
    _max_nq = std::max<int>(_max_nq, _min_nq);
    
    _boundary = args.get_float("boundary-constraint", 1.0f);
    _nbcores = args.get_int( "nbcores", 2 );
    _args = &args;

    {
	int argc = 1;
	char **argv = (char**)malloc((argc+1)*sizeof(char*));

	argv[0] = strdup( "./manao" );
	argv[1] = NULL;

	_dague = dague_init(_nbcores, &argc, &argv);

	free(argv[0]);
	free(argv);
    }
}
开发者ID:belcour,项目名称:alta,代码行数:27,代码来源:rational_fitter.cpp

示例4: call

        bool call(const arguments & args_, std::string & result) {
            //LOG(INFO) << "Calling [" << args_.as_string(0) << "]";

            if (_modules.find(args_.as_string(0)) == _modules.end()) {
                return false;
            }

            result = "";
            result.resize(4096);

            std::string function_str;
            std::vector<std::string> temp = ace::split(args_.get(), ',');

            if (temp.size() < 3) {
                function_str = temp[1];
            } else {
                for (int x = 1; x < temp.size(); x++)
                    function_str = function_str + temp[x] + ",";
            }
            _modules[args_.as_string(0)].function((char *)result.c_str(), 4096, (const char *)function_str.c_str());
#ifdef _DEBUG
            //if (args_.as_string(0) != "fetch_result" && args_.as_string(0) != "ready") {
            //    LOG(INFO) << "Called [" << args_.as_string(0) << "], with {" << function_str << "} result={" << result << "}";
            //}
#endif
            return true;
        }
开发者ID:AgentRev,项目名称:ACE3,代码行数:27,代码来源:dynloader.hpp

示例5: createFile

void FileSystem::createFile(arguments str, outputStream out)
{
    checkArgumentsCount(str, 2);
    std::ofstream::pos_type  size = std::stoll(str.at(1));     // 1234asd321 -> 1234, its ok?
    if(_fsFile->create(str.at(0), size)) {
        out << "File created";
    } else {
        out << "file not created";
    }
    out << "\n";
}
开发者ID:valsid,项目名称:FileSystemForFile,代码行数:11,代码来源:filesystem.cpp

示例6: load

        bool load(const arguments & args_, std::string & result) {
            HMODULE dllHandle;
            RVExtension function;

            LOG(INFO) << "Load requested [" << args_.as_string(0) << "]";

            if (_modules.find(args_.as_string(0)) != _modules.end()) {
                LOG(ERROR) << "Module already loaded [" << args_.as_string(0) << "]";
                return true;
            }

#ifdef _WINDOWS
            // Make a copy of the file to temp, and load it from there, referencing the current path name
            char tmpPath[MAX_PATH +1], buffer[MAX_PATH + 1];

            if(!GetTempPathA(MAX_PATH, tmpPath)) {
                LOG(ERROR) << "GetTempPath() failed, e=" << GetLastError();
                return false;
            }
            if(!GetTempFileNameA(tmpPath, "ace_dynload", TRUE, buffer)) {
                LOG(ERROR) << "GetTempFileName() failed, e=" << GetLastError();
                return false;
            }
            std::string temp_filename = buffer;
            if (!CopyFileA(args_.as_string(0).c_str(), temp_filename.c_str(), FALSE)) {
                DeleteFile(temp_filename.c_str());
                if (!CopyFileA(args_.as_string(0).c_str(), temp_filename.c_str(), FALSE)) {
                    LOG(ERROR) << "CopyFile() , e=" << GetLastError();
                    return false;
                }
            }
#else
            std::string temp_filename = args_.as_string(0);
#endif

            dllHandle = LoadLibrary(temp_filename.c_str());
            if (!dllHandle) {
                LOG(ERROR) << "LoadLibrary() failed, e=" << GetLastError() << " [" << args_.as_string(0) << "]";
                return false;
            }

            function = (RVExtension)GetProcAddress(dllHandle, "[email protected]");
            if (!function) {
                LOG(ERROR) << "GetProcAddress() failed, e=" << GetLastError() << " [" << args_.as_string(0) << "]";
                FreeLibrary(dllHandle);
                return false;
            }

            LOG(INFO) << "Load completed [" << args_.as_string(0) << "]";

            _modules[args_.as_string(0)] = module(args_.as_string(0), dllHandle, function, temp_filename);

            return false;
        }
开发者ID:AgentRev,项目名称:ACE3,代码行数:54,代码来源:dynloader.hpp

示例7: cd

void FileSystem::cd(arguments arg)
{
    checkArgumentsCount(arg, 1);
    _currentFolder = getLastPathElementHandle(arg.at(0))
            .descriptorHandle();
//    auto v = p.getParsedPath();
}
开发者ID:valsid,项目名称:FileSystemForFile,代码行数:7,代码来源:filesystem.cpp

示例8: debug_script

void debug_script( const arguments &args )
{
    const path script( absolute( path( args[ 2 ] ), cwd() ) );

    Config config( get_config() );

    const string exe( get_executable( config, script, debug ).string() );

    const string debug_script( debug_script_path( config, script ).string() );

    ofstream stream( debug_script.c_str() );

    stream << "file " << exe << endl
                 << "r ";
    for ( size_t i = 3; i < args.size(); ++i )
    {
        stream << args[ i ] << ' ';
    }
    stream << endl << "q" << endl;

    stream.close();

    // for some reason, lldb won't start in execv
    exit( system( ( config.debugCommand() + " -s " + debug_script ).c_str() ) );
//	execv( config.debugCommand().c_str(), argv + 1 );
}
开发者ID:arjanhouben,项目名称:nativescript,代码行数:26,代码来源:nativescript.cpp

示例9: filestat

void FileSystem::filestat(arguments arg, outputStream out)
{
    checkArgumentsCount(arg, 1);
    uint64_t descriptorId = std::stoll(arg.at(0));

    FSDescriptor descriptor;
    try {
        descriptor = _descriptors.getDescriptor(descriptorId);
    } catch(const std::invalid_argument &) {
        out << "Bad descriptor\n";
        return;
    }

    if(descriptor.type == DescriptorVariant::None) {
        out << "Descriptor does not exist\n";
        return;
    }

    using std::to_string;

    out << "File statistic: \n\tid: " << descriptorId;
    if(descriptor.type == DescriptorVariant::File) {
        out << descriptor.fileSize;
    }
    out << "\n\tType: "     << to_string(descriptor.type) <<
           "\n\tReferences: " << descriptor.referencesCount <<
           "\n\tHas extended blocks: " << (descriptor.nextDataSegment == Constants::HEADER_ADDRESS() ? "false" : "true") << "\n";
}
开发者ID:valsid,项目名称:FileSystemForFile,代码行数:28,代码来源:filesystem.cpp

示例10: brdf_slice_parameters

// Allow for a different parametrization depending on the arguments provided.
static const alta::parameters
brdf_slice_parameters(const arguments& args)
{
    auto result = alta::parameters(2, 3,
                                   params::STARK_2D, params::RGB_COLOR);

    if(args.is_defined("param")) {
				params::input param = params::parse_input(args["param"]);

				// The param is a 2D param
				if(params::dimension(param) == 2) {
            std::cout << "<<INFO>> Specified param \"" << args["param"] << "\"" << std::endl;
            result = alta::parameters(result.dimX(), result.dimY(),
                                      param, result.output_parametrization());

            // The oaram is a 3D param
				} else if(params::dimension(param) == 3) {
            std::cout << "<<INFO>> Specified param \"" << args["param"] << "\"" << std::endl;
            result = alta::parameters(3, result.dimY(),
                                      param, result.output_parametrization());

				} else {
            std::cout << "<<ERROR>> Invalid specified param \"" << args["param"] << "\"" << std::endl;
            std::cout << "<<ERROR>> Must have 2D input dimension" << std::endl;
				}
    }

    return result;
}
开发者ID:belcour,项目名称:alta,代码行数:30,代码来源:slice.cpp

示例11: call

        bool call(const std::string & name_, arguments & args_, std::string & result_, bool threaded) {
            if (_methods.find(name_) == _methods.end()) {
                // @TODO: Exceptions
                return false;
            }
            if (threaded) {
                std::lock_guard<std::mutex> lock(_messages_lock);
                _messages.push(dispatch_message(name_, args_, _message_id));
                
                // @TODO: We should provide an interface for this serialization.
                std::stringstream ss;
                ss << "[\"result_id\", " << _message_id << "]";
                result_ = ss.str();

                _message_id = _message_id + 1;
            } else {
#ifdef _DEBUG
                if (name_ != "fetch_result") {
                    LOG(TRACE) << "dispatch[immediate]:\t[" << name_ << "] { " << args_.get() << " }";
                }
#endif
                return dispatcher::call(name_, args_, result_);
            }

            return true;
        }
开发者ID:IDI-Systems,项目名称:acre2,代码行数:26,代码来源:dispatch.hpp

示例12: create

void FileSystem::create(arguments arg)
{
    checkArgumentsCount(arg, 1);
    FSDescriptor fileDescriptor;
    fileDescriptor.initFile();
    allocAndAppendDescriptorToCurrentFolder(fileDescriptor, arg.at(0));
}
开发者ID:valsid,项目名称:FileSystemForFile,代码行数:7,代码来源:filesystem.cpp

示例13: mkdir

void FileSystem::mkdir(arguments arg)
{
    checkArgumentsCount(arg, 1);
    FSDescriptor fileDescriptor;
    fileDescriptor.initDirectory(currentDirectory());
    string name = arg.at(0);
    allocAndAppendDescriptorToCurrentFolder(fileDescriptor, name);
}
开发者ID:valsid,项目名称:FileSystemForFile,代码行数:8,代码来源:filesystem.cpp

示例14: standard_arguments

void fostlib::standard_arguments(
    const loaded_settings &settings,
    ostream &out,
    arguments &args
) {
    args.commandSwitch( L"b", settings.name, L"Banner" );
    if ( settings.c_banner.value() )
        out << settings.banner << std::endl;

    args.commandSwitch( L"s", settings.name, L"Settings" );
    if ( settings.c_settings.value() )
        setting< json >::printAllOn( out );

    args.commandSwitch( L"e", settings.name, L"Environment" );
    if ( settings.c_environment.value() )
        args.printOn( out );
}
开发者ID:KayEss,项目名称:fost-base,代码行数:17,代码来源:main_exec.cpp

示例15: mount

void FileSystem::mount(arguments str)
{
    checkArgumentsCount(str, 1);
    _fsFile->open(str.at(0));
    if(_fsFile->isFormatedFS()) {
        fileFormatChanged();
    } else {
    }
}
开发者ID:valsid,项目名称:FileSystemForFile,代码行数:9,代码来源:filesystem.cpp


注:本文中的arguments类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。