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


C++ settings类代码示例

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


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

示例1: displayNumber

void displayNumber(bigNumber &bn, settings &user, bool exact, bool stats)
{
	if (exact)
		bn.printNumber();

	else
	{
		int actualDigits = bn.getDigitCount() - (PRECISION-bn.getDecimalCount());
		
		if (user.getPercent())
		{
			bn.printPercent(user.getRound());
		}
					
		else 
		{
		    bn.printNumber(user.getRound());
		}

		if (user.getShowDigits() && stats==true)
		{
			cout << endl;
			cout << "Digits: ";
			if (bn<1 && bn > -1 && bn != 0)
				cout << actualDigits - 1;

			else cout << actualDigits;

			cout << "\nDecimal places: " << bn.getDecimalCount();
			cout << "\nBase: " << bn.getBase();
		}
	}
}
开发者ID:eindacor,项目名称:utilities,代码行数:33,代码来源:main.cpp

示例2: validate

void validator::validate(const settings& s) {
    if (s.modeling().target().empty()) {
        BOOST_LOG_SEV(lg, error) << missing_target;
        BOOST_THROW_EXCEPTION(configuration_error(missing_target));
    }

    const auto cpp(s.cpp());
    if (cpp.split_project()) {
        if (cpp.include_directory().empty() || cpp.source_directory().empty()) {
            BOOST_LOG_SEV(lg, error) << missing_source_include;
            BOOST_THROW_EXCEPTION(configuration_error(missing_source_include));
        }

        if (!cpp.project_directory().empty()) {
            BOOST_LOG_SEV(lg, error) << unexpected_project_dir;
            BOOST_THROW_EXCEPTION(configuration_error(unexpected_project_dir));
        }
    } else {
        if (!cpp.include_directory().empty() || !cpp.source_directory().empty()) {
            BOOST_LOG_SEV(lg, error) << unexpected_source_include;
            BOOST_THROW_EXCEPTION(configuration_error(unexpected_source_include));
        }

        if (cpp.project_directory().empty()) {
            BOOST_LOG_SEV(lg, error) << missing_project_dir;
            BOOST_THROW_EXCEPTION(configuration_error(missing_project_dir));
        }
    }
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例3: proxy

channel::channel(threadpool& pool, asio::socket_ptr socket,
    const settings& settings)
  : proxy(pool, socket, settings.identifier),
    nonce_(0),
    version_({ 0 }),
    located_start_(null_hash),
    located_stop_(null_hash),
    revival_handler_(nullptr),
    expiration_(alarm(pool, pseudo_randomize(settings.channel_expiration()))),
    inactivity_(alarm(pool, settings.channel_inactivity())),
    revival_(alarm(pool, settings.channel_revival())),
    CONSTRUCT_TRACK(channel, LOG_NETWORK)
{
}
开发者ID:zauguin,项目名称:libbitcoin,代码行数:14,代码来源:channel.cpp

示例4:

void
ssl_context::init(settings const &s) {

	context_.set_options(asio::ssl::context::default_workarounds);

	std::string cacert = s.ssl_cacert_file_name();
	if (!cacert.empty()) {
		context_.load_verify_file(cacert.c_str());
	}

	std::string cert = s.ssl_cert_file_name();
	if (!cert.empty()) {
		//context_.use_certificate_file(cert.c_str(), asio::ssl::context::pem);
		context_.use_certificate_chain_file(cert.c_str());
		context_.use_private_key_file(cert.c_str(), asio::ssl::context::pem);
	}
}
开发者ID:GunioRobot,项目名称:xiva,代码行数:17,代码来源:ssl_context.cpp

示例5:

void
threaded_listener::init(settings const &s) {
	if (!empty()) {
		boost::function<void()> f = boost::bind(&threaded_listener::thread_func, this);
		unsigned short threads = s.listener_threads();
		for (unsigned short i = 0; i < threads; ++i) {
			create_thread(f);
		}
	}
}
开发者ID:Leonya,项目名称:xiva,代码行数:10,代码来源:threaded_listener.cpp

示例6: start

void protocol_ping::start(const settings& settings)
{
    protocol_timer::start(settings.channel_heartbeat(),
        BIND1(send_ping, _1));

    SUBSCRIBE2(ping, handle_receive_ping, _1, _2);

    // Send initial ping message by simulating first heartbeat.
    set_event(error::success);
}
开发者ID:zauguin,项目名称:libbitcoin,代码行数:10,代码来源:protocol_ping.cpp

示例7:

void
threaded_listener::init(settings const &s) {
    if (!empty()) {
        unsigned short threads = s.listener_threads();
        if (!threads) {
            threads = 1;
        }
        for (unsigned int i = 0; i < threads; ++i) {
            items_.push_back(boost::shared_ptr<queue_type>(new queue_type()));
            boost::function<void()> f = boost::bind(&threaded_listener::thread_func, this, i);
            create_thread(f);
        }
    }
}
开发者ID:highpower,项目名称:xiva,代码行数:14,代码来源:threaded_listener.cpp

示例8: template_factory

void protocol_version::start(const settings& settings, size_t height,
                             event_handler handler)
{
    const auto self = template_factory(authority(), settings, nonce(), height);

    // The synchronizer is the only object that is aware of completion.
    const auto handshake_complete =
        BIND2(handle_handshake_complete, _1, handler);

    protocol_timer::start(settings.channel_handshake(),
                          synchronize(handshake_complete, 3, NAME));

    SUBSCRIBE2(version, handle_receive_version, _1, _2);
    SUBSCRIBE2(verack, handle_receive_verack, _1, _2);
    SEND1(self, handle_version_sent, _1);
}
开发者ID:zauguin,项目名称:libbitcoin,代码行数:16,代码来源:protocol_version.cpp

示例9: numberFromVector

bigNumber numberFromVector(vector<int> &vec, bool neg, int dec, settings &user)
{
	bigNumber temp;
	temp.setBase(user.getBase());

	for (int i=0; i<vec.size(); i++)
	{
		int numberToUse = vec.at(vec.size()-i-1);
		int locationToSet = PRECISION + i;
		temp.setDigit(locationToSet, numberToUse);
	}
	
	if (neg)
		temp.setNegative();

	temp.divideByTen(dec);

	return temp;
}
开发者ID:eindacor,项目名称:utilities,代码行数:19,代码来源:main.cpp

示例10: solve

solution solve(string &c, bigNumber previous, settings &user)
{
    c += '$';
    PTYPE pType=ERROR;
    
    vector<int> first;
    vector<int> second;
    bigNumber bn1;
    bigNumber bn2;
    bigNumber temp;
    
    bn1.setBase(user.getBase());
    bn2.setBase(user.getBase());
    temp.setBase(user.getBase());

    int decimalCount1=0;
    int decimalCount2=0;
    int commaNumbers=0;
    int numbers=0;

    bool decimal=false;
	bool comma=false;
	bool negative1=false;
	bool negative2=false;
    bool done=false;
	bool printExact=false;
	bool printStats=false;

    bigNumber* targetBN = &bn1;
    vector<int>* targetVec = &first;
    int* targetDec = &decimalCount1;
	bool* targetNegative = &negative1;
    
    int counter = c.size();
    
    for (int i=0; i<counter; i++)
    {
        if (checkWord(c, i, "pi"))
        {
            if (numbers>0 || comma==true || decimal==true)
            {
                RETURN_ERROR;
            }
            
            else
            {
                string piString(PI);
		
				for (int piMarker=PRECISION; piMarker>=0; piMarker--)
				{
					char piChar = '0';
					int piNum = piString[PRECISION-piMarker] - piChar;
				
					(*targetVec).push_back(piNum);
				}
                
                done=true;
				*targetDec = PRECISION;
                
                numbers += (PRECISION+1);
                counter += 2;
                i += 2;
            }
        }
        
        if (checkWord(c, i, "theta"))
        {
            if (numbers>0 || comma==true || decimal==true)
            {
                RETURN_ERROR;
            }
            
            else
            {
                string thetaString(THETA);
		
				for (int thetaMarker=PRECISION; thetaMarker>=0; thetaMarker--)
				{
					char thetaChar = '0';
					int thetaNum = thetaString[PRECISION-thetaMarker] - thetaChar;
				
					(*targetVec).push_back(thetaNum);
				}
                
                done=true;
				*targetDec = PRECISION;
                
                numbers += (PRECISION+1);
                counter += 5;
                i += 5;
            }
        }
        
		//if it isn't a space, number, symbol, end marker, or decimal point, return error
		if (checkSpace(c[i])==false && 
			isNumber(c[i], user)==false && 
			isSymbol(c[i])==false && 
			c[i] != '$' && 
			c[i] != ',' && 
			c[i] != '.')
//.........这里部分代码省略.........
开发者ID:eindacor,项目名称:utilities,代码行数:101,代码来源:main.cpp

示例11: modifySettings

void modifySettings(settings &user)
{
    cout << endl;
    string setI;
    string setS;
    bool invalid=false;
    int intSet=0;
    
    do
    {
		intSet=0;
        invalid=false;
        setI.clear();
        
        cout << "Enter desired precision: ";
        std::getline(cin, setI);
        
        for (int i=0; i<setI.size(); i++)
        {
			int target = setI.size()-i-1;
			
            if (checkNumber(setI[target]) < 0 || checkNumber(setI[target]) > 9)
            {
                cout << "Invalid entry" << endl << endl;
                invalid=true;
                break;
            }
            
            else intSet += (checkNumber(setI[target]) * pow(10, i));
        }
        
        if (invalid==false)
        {
            if (intSet>PRECISION)
            {
                cout << "Invalid entry (precision must be between 0 and " << PRECISION << ")" << endl << endl;
                invalid=true;
            }
            
            else 
            {
                user.setRound(intSet);
            }
        }
    } while (invalid==true);
    
    do
    {
		intSet=0;
        invalid=false;
        setI.clear();
        
        cout << "Enter desired base: ";
        std::getline(cin, setI);
        
        for (int i=0; i<setI.size(); i++)
        {
			int target = setI.size()-i-1;
			
            if (checkNumber(setI[target]) < 0 || checkNumber(setI[target]) > 9 )
            {
                cout << "Invalid entry" << endl << endl;
                invalid=true;
                break;
            }
            
            else intSet += (checkNumber(setI[target]) * pow(10, i));
        }
    
        
        if (invalid==false)
        {
            if (intSet < 2 || intSet > 36)
            {
                cout << "Invalid entry (base must be between 2 and 36)" << endl << endl;
                invalid=true;
            }
            
            else 
            {
                user.setBase(intSet);
            }
        }
        
    } while (invalid==true);
    
    for (;;)
    {
      
        if (user.getPercent())
        {
            setS.clear();
            cout << "Turn off percentages? ";
            std::getline(cin, setS);
            
            if (setS=="yes" || setS=="y")
            {
                user.percentOff();
                break;
            }
//.........这里部分代码省略.........
开发者ID:eindacor,项目名称:utilities,代码行数:101,代码来源:main.cpp

示例12: atoi

//
// processDisk() - called when a disk is discovered and properly located
//                 on P2.  This routine does everything that the Chapr can
//                 do with a flash drive, like update the name of the Chapr.
//
void VDIP::processDisk(portConfig *portConfigBuffer)
{    
     char buf[BIGENOUGH];

     // check that it's in port two (beep annoyingly otherwise)

     if(portConfigBuffer->port == 1) {

       // read through VDIP stuff looking for a text file with the name, personality etc.

       // PLEASE NOTE -- FILE NAMES MUST BE FEWER THAN 8 CHARACTERS

       // get the new name of the ChapR

       if(readFile("name.txt", buf, BIGENOUGH)){
         if (buf[EEPROM_NAMELENGTH - 1] == '\0'){
           myEEPROM.setName(buf);
         }
       }

       // get the new personality

       if(readFile("person.txt", buf, BIGENOUGH)){
         byte newNum = (byte) atoi(buf);
         if (newNum > 0 && newNum <= EEPROM_LASTPERSON){
           myEEPROM.setPersonality(newNum);
         }
       }

       // get the power-down timeout

       if(readFile("timeout.txt", buf, BIGENOUGH)){
         byte newNum = (byte) atoi(buf);
         if (newNum >= 0 && newNum <= EEPROM_MAXTIMEOUT){
         myEEPROM.setTimeout(newNum);
         }
       }

       // get the lag time

       if(readFile("lag.txt", buf, BIGENOUGH)){
         byte newNum = (byte) atoi(buf);
         if (newNum >= 0 && newNum <= EEPROM_MAXLAG){
         myEEPROM.setSpeed(newNum);
         }
       }

       // get the user mode

       if(readFile("mode.txt", buf, BIGENOUGH)){
         byte newNum = (byte) atoi(buf);
         if (newNum >= 0 && newNum <= EEPROM_MAXMODE){
         myEEPROM.setMode(newNum);
         }
       }
       
       // allows user to determine number of seconds in autonomous, teleOp and endgame (ChapR3 of EEPROM)
       // zero for either mode skips the mode

       if(readFile("mConfig.txt",buf, BIGENOUGH)){
	 char *ptr = buf;
	 for (int i = 0; i < 3; i++){
	   switch(i){
	   case 0: myEEPROM.setAutoLen(atoi(ptr));break;
	   case 1: myEEPROM.setTeleLen(atoi(ptr));break;
	   case 2: myEEPROM.setEndLen(atoi(ptr));break;
	   }
	   while (*ptr != '\r' && *ptr != '\0' && *ptr != '\n'){
	     ptr++;
	   }
	   while (*ptr == '\r' && *ptr == '\n'){
	     ptr++;
	   }
	   if (*ptr == '\0'){
	     break;
	   }
	 }
       }
     

       // contains the settings for the digital I/O pins (for FRC, aka ChapR3 of EEPROM)
     
       if (readFile("dgtlIn.txt", buf, BIGENOUGH)){
	 byte newNum = 0;
	 
	 for (int i = 0, ptr = 0; i < 8; i++){
	   byte bit = (buf[ptr] == '1')?1:0;
	   newNum |= bit<<i;
	   while (buf[ptr] != '\r' && buf[ptr] != '\0' && buf[ptr] != '\n'){
	     ptr++;
	   }
	   while (buf[ptr] == '\r' || buf[ptr] == '\n'){
	     ptr++;
	   }
	   if (buf[ptr] == '\0'){
//.........这里部分代码省略.........
开发者ID:ChapResearch,项目名称:ChapR,代码行数:101,代码来源:VDIP.cpp

示例13: note_sequence

    note_sequence(settings &set) {
      if (set.note_mode() == settings::note_mode_list) {
        impl_.reset(new detail::listed_sqeuence(
              set.concert_pitch(),
              set.note_list().begin(), set.note_list().end(),
              set.note_list().size()));
      }
      else {
        assert(set.note_mode() == settings::note_mode_start);
        trc("using a start note and distance");
        int start_offset = parse_note(set.start_note().c_str());

        int stop_offset;
        if (! set.end_note().empty()) {
          stop_offset = parse_note(set.end_note().c_str());
        }
        else if (set.num_notes() >= 0) {
          stop_offset = start_offset + set.num_notes() * set.note_distance();
        }
        else {
          stop_offset = start_offset + 12;
        }

        int step = set.note_distance();
        if (start_offset > stop_offset && step > 0) {
          std::cerr << "warning: making the step negative since the end note is lower than the start note." << std::endl;
          step = -step;
        }
        else if (start_offset < stop_offset && step < 0) {
          std::cerr << "warning: making the step positive since the end note is higher than the start note." << std::endl;
          step = -step;
        }

        trc("start: " << start_offset);
        trc("stop:  " << stop_offset);
        trc("step:  " << step);

        impl_.reset(
          new detail::generated_sequence(
            set.concert_pitch(), start_offset, stop_offset, step
          )
        );
        trc("done");
        assert(impl_.get());
      }
    }
开发者ID:bnkr,项目名称:tune,代码行数:46,代码来源:note_sequence.hpp

示例14: isNumber

bool isNumber(char const &c, settings &user)
{
	return (checkNumber(c) >= 0 && checkNumber(c) <= (user.getBase()-1) );
}
开发者ID:eindacor,项目名称:utilities,代码行数:4,代码来源:main.cpp

示例15: MatchReset

//
// Loop() - for the NXT-RobotC pesonality, a message is sent out for each
//		loop through the Arduino code.  The message is simply the
//		appropriately formatted BT message with the translation of
//		the Gamepads and inclusion of the button.
//
void Personality_0::Loop(BT *bt, Gamepad *g1, Gamepad *g2)
{
     byte	msgbuff[64];	// max size of a BT message
     int	size;

     // if we're not connected to Bluetooth, then ingore the loop
     if (!bt->connected()) {
          enabled = false;
	  if (isMatchActive()){
	    MatchReset();
	  }
	  return;
     }
       
     // only deal with matchmode when it is active

     if (isMatchActive()){
	     MatchLoopProcess((void *)bt);	// mode is set in the match callback above
     } else {
	     mode = myEEPROM.getMode();		// mode is set by the EEPROM setting
     }

     // first convert the gamepad data and button to the robotC structure
     size = robotcTranslate(msgbuff,enabled,g1,g2, mode);

     // then compose a NXT mailbox message (for BT transport) with that data
     // this routine operates within the given buffer.  Note that the
     // mailbox used is #0.
     size = nxtBTMailboxMsgCompose(0,msgbuff,size);

     // then send it over BT, again, operating on the message buffer
     (void)bt->btWrite(msgbuff,size);
}
开发者ID:ChapResearch,项目名称:ChapR,代码行数:39,代码来源:personality_0.cpp


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