Beispiel #1
0
long strxl(char strg[], int pos, int len)
{
 char *ptr;
 long val;
 int bpos;
 if (len < 0)
   {
    pos = pos - strbegin;
    bpos = strspn(strg+pos," ");
    pos = pos + bpos;
    strncpy(buffer,strg+pos,40);
    pos = pos + strbegin;
    buffer[41] = 0;
   }
 else
   {
    strs(buffer,strg,pos,(len > 255 ? 255 : len));
   }
 bpos = strspn(buffer," ");
 if ((buffer[bpos] == '0') && (toupper(buffer[bpos+1]) == 'X'))
   {
    bpos += 2;
   }
 if (buffer[bpos] == '$')
   {
    bpos++;
   }
 val = strtol(buffer+bpos,&ptr,16);
 if (len < 0)      /* len < 0: stop at first inconsistent char */
    strpos = pos + (int)(ptr - buffer);
 return val;
}
Beispiel #2
0
// ######################################################################
void HMR3300::run()
{
  unsigned char c = 255;
  while(itsKeepgoing)
    {
      // skip to next LF:
      while(c != '\n') c = itsSerial->read();

      // get data until next LF:
      std::string str;
      while( (c = itsSerial->read() ) != '\n')
         if (isdigit(c) || c == '.' || c == '-') str += c;
          else str += ' ';
      // convert to doubles:
        std::stringstream strs(str);
       double hh, pp, rr; strs >> hh >> rr >> pp;

      // update our internal data:
      pthread_mutex_lock(&itsLock);
      itsHeading = hh; itsPitch = pp; itsRoll = rr;
      pthread_mutex_unlock(&itsLock);

      // if we have a listener, let it know:
      if (itsListener.is_valid()) itsListener->newData(hh, pp, rr);
    }

  pthread_exit(0);
}
Beispiel #3
0
void Counter::loadRes()
{
    if(!loaded)
    {
        digits= new Object::Animation;
        digits->addRes(strs("0.png","1.png","2.png","3.png","4.png","5.png","6.png","7.png","8.png","9.png",0),0);
       loaded=true;
    }
}
Beispiel #4
0
detail::match_helper match_split(const std::string& str, char delim, bool keep_empties) {
    vector<string> result;
    stringstream strs(str);
    string tmp;
    while (getline(strs, tmp, delim)) {
        if (!tmp.empty() && !keep_empties) result.push_back(std::move(tmp));
    }
    return match(any_tuple::view(std::move(result)));
}
int main(int argc, char **argv) {//Not much to do here
	NLS::console = new NLS::Console();
	vector<string> strs(argv, argv+argc);
	//Actually run NLS here
	NLS::Init(strs);
	while (NLS::Loop()) {}
	NLS::Unload();
	delete NLS::console;
	return 0;
}
int main() {
    vector<string> strs(2, "");
    while (true) {
        if (!getline(cin, strs[0])) break;
        getline(cin, strs[1]);
        
        cout << join(strs, ", ") << endl;
    }

  return 0;
}
Beispiel #7
0
owl_filter *owl_filter_new_fromstring(const char *name, const char *string)
{
  owl_filter *f;
  char **argv;
  int argc;

  argv = owl_parseline(string, &argc);
  f = owl_filter_new(name, argc, strs(argv));
  owl_parse_delete(argv, argc);

  return f;
}
Beispiel #8
0
void StackWalker::getSymbolName(
    void *symbolLocation,
    Eks::String &symbolName,
    xsize maxSize)
  {
  (void)symbolLocation;
  (void)symbolName;
  (void)maxSize;
#if X_ENABLE_STACK_WALKING
#ifdef Q_CC_MSVC
  BYTE *buffer = (BYTE *)alloca(sizeof(SYMBOL_INFO) + maxSize);
  memset(buffer, 0, sizeof(buffer));

  PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
  symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
  symbol->MaxNameLen = (ULONG)maxSize;

  DWORD64 symDisplacement = 0;
  if (!SymFromAddr(::GetCurrentProcess(),
                   reinterpret_cast<xsize>(symbolLocation),
                   &symDisplacement,
                   symbol))
    {
    symbol->Name[0] = 0;
    symDisplacement = 0;
    }

  symbolName.clear();
  symbolName.resizeAndCopy(strlen(symbol->Name), symbol->Name);

#elif defined(X_OSX)
  std::unique_ptr<char *, void (*)(void *)> strs(backtrace_symbols(&symbolLocation, 1), std::free);

  if (strs && strs.get()[0])
    {
    symbolName = strs.get()[0];
    if (symbolName.length() > maxSize)
      {
      symbolName.resize(maxSize, '\0');
      }
    }

#else
  (void)symbolLocation;
  (void)symbolName;
  (void)maxSize;
#endif
#else
#endif
  }
Beispiel #9
0
int
SFTP::handle_from_string(const char *handle, u_int hlen)
{
	int val;

	if (hlen == 0)
		return -1;

  std::istringstream strs (handle);
  strs >> val; //TODO if bad formed string

  if (handle_is_ok(val, HANDLE_FILE) ||
	    handle_is_ok(val, HANDLE_DIR))
		return val;
  throw NoSuchHandle (val);
}
Beispiel #10
0
std::string getTime()
{
	time_t roxtime;
	struct tm	stime;

	time(&roxtime);
	gmtime_s(&stime, &roxtime);
	std::ostringstream strs(stime.tm_year % 100 + 2000);
	strs << (stime.tm_year % 100 + 2000)
		<< '-' << (stime.tm_mon)
		<< '-' << (stime.tm_mday)
		<< ' ' << (stime.tm_hour % 24)
		<< ':' << (stime.tm_min)
		<< " UTC";
	return strs.str();
}
Beispiel #11
0
std::vector<std::string>
DataSetIO::UnpackString(const std::string& str_, char delimiter_){
    // count instances
    unsigned count = 0;
    for (size_t i = 0; i < str_.size(); i++)
        if(str_.at(i) == delimiter_)
            count++;

    std::vector<std::string> strs(count + 1); // one more string than delimiter a:b
    size_t currentStr = 0;
    for(size_t i = 0; i < str_.size(); i++){
        if(str_[i] == delimiter_)
            currentStr++;
        else
            strs[currentStr] += str_[i];
    }
    
    return strs;
}
Beispiel #12
0
    string largestNumber(vector<int>& nums) {
        vector<string> strs(nums.size());
        for (int i = 0; i < nums.size(); i++) {
            strs[i] = to_string(nums[i]);
        }

        sort(strs.begin(), strs.end(), [](const string& a, const string& b) -> bool {
            return a+b > b+a;
        });

        if (strs[0][0] == '0') {
            return "0";
        }

        string ans;
        for (const string& s : strs) {
            ans += s;
        }
        return ans;
    }
Beispiel #13
0
/* caller must free the return */
CALLER_OWN char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff)
{
  char **argv;
  int argc;
  char *retval = NULL;

  argv = owl_parseline(cmdbuff, &argc);
  if (argv == NULL) {
    owl_function_makemsg("Unbalanced quotes");
    return NULL;
  } 
  
  if (argc < 1) {
    g_strfreev(argv);
    return NULL;
  }

  retval = _owl_cmddict_execute(cd, ctx, strs(argv), argc, cmdbuff);

  g_strfreev(argv);
  return retval;
}
Beispiel #14
0
int main() {
	vetor<string> strs2(3);
	vetor<string> strs(3);

	strs.push_back("a");
	strs.push_back("b");
	strs.push_back("c");

	strs2 = strs;

	cout << strs.pop_back()<<endl;
	cout << strs2.pop_back()<<endl;



	cout << (strs == strs2)<<endl;
	cout << "====="<<endl;
	cout <<strs.Find("c")<<endl;
	cout << "====="<<endl;
	cout <<strs.size()<<endl;

	return 0;
}
Beispiel #15
0
int main(int argc, char *argv[]) {
  if(argc < 8) {
      std::cout<<"We need beginId, batchSize, expiredTime, zkAddress, namespaceId, businessId ,warmtype and warmservers! Correct way to use this is : ./exec beginId batchSize expiredTime zkAddress namespaceId businessId warmtype[all|hot] warmservers[ip:port]"<<std::endl;
      return 0;
  }

  std::string beginId(argv[1]);
  int batchSize = boost::lexical_cast<int>(argv[2]);
  int expiredTime = boost::lexical_cast<int>(argv[3]);
  std::string zkAddress(argv[4]);
  std::string namespaceId(argv[5]);
  std::string businessId(argv[6]);
  std::string warmtype(argv[7]);

  if(warmtype != "all" | warmtype != "hot") {
      std::cout<<"Warmtype must be all or hot!"<<std::endl;
      return 0;
  }
  

  bool hotKey = false;
  if(warmtype == "hot") {
      hotKey = true;
  }

  std::vector<std::string> prxVec;

  for(int i = 8; i < argc; ++i) {
      std::string strs(argv[i]);
      std::vector<std::string> parts;
      boost::algorithm::split(parts, strs, boost::algorithm::is_any_of(":"));
      if(parts.size() != 2) {
          std::cout<<"Warmserver must be <ip>:<port>!";
          return 0;
      }
      prxVec.push_back(strs);
  }

  bool warmServers = false;

  if(!prxVec.empty()) {
      warmServers = true;
  }

  com::renren::tripod::ProducerManagerClientPtr producer = com::renren::tripod::ClientFactory::getInstance()->getProducerManagerClient(zkAddress);
  if(producer == NULL) {
      std::cout<<"Can not get producer!"<<std::endl;
      return 0;
  }
  
  com::renren::tripod::CacheConfigClientPtr cacheConfig = com::renren::tripod::ConfigClientFactory::getInstance()->getCacheConfigClient(zkAddress);
  if(cacheConfig == NULL) {
      std::cout<<"Can not get cacheconfig!"<<std::endl;
      return 0;
  }
  
  com::renren::tripod::TripodClient tripodClient(zkAddress, namespaceId, businessId);

  while(true) {
      com::renren::tripod::KeySeq keys; 
      try {
          keys = producer->produceKeys(beginId, batchSize, businessId, hotKey, 300);
      }catch(...) {
          continue;
      }

      if(keys.empty()) {
          break;
      }

      com::renren::tripod::KeySeq warmKeys;

      if(warmServers) {
          warmKeys = cacheConfig->getFilterKeys(keys, prxVec, namespaceId);
      }else {
          warmKeys = keys;
      }

      if(!warmKeys.empty()) {
          try {
              tripodClient.load(warmKeys, expiredTime, false, 10 * 1000);
          }catch(...) {
          }
      }

      beginId = keys[keys.size() -1];

  }

  std::cout<<"Done!"<<std::endl;

  return 1;
}
Beispiel #16
0
int LuaGenerator::parameter(lua_State *L, int index)
{
    const char *typedname = luaL_checkstring(L, index);

    core::ParamType type;
    if (type.fromstring(typedname, NULL) == false)
        return luaL_error(L, "TypeError: Cannot parse parameter type.");

    bool istable = lua_istable(L, index + 1);

    int totalElements = type.type.numelements() * type.type.aggregate;

    if (totalElements > 1 && !istable)
        return luaL_error(L, "TypeError: Cannot pass single value to an array/vector/matrix type.");

    switch (type.type.basetype)
    {
    case OIIO::TypeDesc::FLOAT:
    {
        if (istable)
        {
            int n = luaL_getn(L, index + 1);
            std::vector<float> floats(n);
            for (int i = 0; i < n; ++i)
            {
                lua_rawgeti(L, index + 1, i + 1);
                floats[i] = luaL_checknumber(L, -1);
                lua_pop(L, 1);
            }
            api_->parameter(typedname, tokenize(floats));
        }
        else
        {
            api_->parameter(typedname, luaL_checknumber(L, index + 1));
        }
        break;
    }
    case OIIO::TypeDesc::INT:
    {
        if (istable)
        {
            int n = luaL_getn(L, index + 1);
            std::vector<int> ints(n);
            for (int i = 0; i < n; ++i)
            {
                lua_rawgeti(L, index + 1, i + 1);
                ints[i] = luaL_checkint(L, -1);
                lua_pop(L, 1);
            }
            api_->parameter(typedname, tokenize(ints));
        }
        else
        {
            api_->parameter(typedname, luaL_checkint(L, index + 1));
        }
        break;
    }
    case OIIO::TypeDesc::STRING:
    {
        if (istable)
        {
            int n = luaL_getn(L, index + 1);
            std::vector<const char*> strs(n);
            for (int i = 0; i < n; ++i)
            {
                lua_rawgeti(L, index + 1, i + 1);
                strs[i] = luaL_checkstring(L, -1);
                lua_pop(L, 1);
            }
            api_->parameter(typedname, tokenize(strs));
        }
        else
        {
            api_->parameter(typedname, tokenize(luaL_checkstring(L, index + 1)));
        }
        break;
    }
    default:
        return luaL_error(L, "TypeError: Unsupported base type.");
    }

    return 0;
}
Beispiel #17
0
void edit_side(int source,int smer)
  {
  TSTENA *p;
  CTL3D b1,b2,b3;
  char s[200];

  p=&mapa.sidedef[source][smer];
  memcpy(&b1,def_border(1,0),sizeof(CTL3D));
  memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D));
  memcpy(&b3,def_border(6,WINCOLOR),sizeof(CTL3D));
  default_font=vga_font;
  memcpy(f_default,flat_color(0x0000),sizeof(charcolors));
  sprintf(s,"Vlastnosti stˆn, sektor %d stˆna %d",source,smer);
  def_window(400,324,s);
  waktual->x=125;
  waktual->y=60;
  waktual->modal=1;
  define(CANCEL_BUTT,10,5,80,20,2,button,"Zru¨it");property(&b1,NULL,NULL,WINCOLOR);
    on_change(close_current);
  define(OK_BUTT,190,5,80,20,2,button,"Ok");property(&b1,NULL,NULL,WINCOLOR);
    on_change(edit_side_ok);
  define(3400,100,5,80,20,2,button,"P©edvolba");property(&b1,NULL,NULL,WINCOLOR);
    on_change(edit_side_predvolba_1);on_exit(edit_side_predvolba_2);
  define(10,5,20,300,35,0,label,"Prim rn¡:       Sekundarn¡:       Oblouk:");property(&b3,NULL,NULL,WINCOLOR);
  define(20,10,35,90,12,0,str_line,side_names);property(&b2,NULL,NULL,WINCOLOR);c_default(p->prim);
    on_enter(string_list_sup);
  define(30,110,35,90,12,0,str_line,side_names);property(&b2,NULL,NULL,WINCOLOR);c_default(p->sec);
    on_enter(string_list_sup);
  define(40,210,35,90,12,0,str_line,oblouky);property(&b2,NULL,NULL,WINCOLOR);c_default(p->oblouk & 0x0f);
    on_enter(string_list_sup);
  define(-1,5,60,250,12,0,label,"Animace primarn¡:");
  define(-1,5,75,250,12,0,label,"Animace sekundarn¡:");
  define(-1,5,90,250,12,0,label,"X pozice sek. stˆny:");
  define(-1,5,105,250,12,0,label,"Y pozice sek. stˆny:");
  define(-1,5,120,250,12,0,label,"C¡lov˜ sektor ud losti:");
  define(-1,5,135,250,12,0,label,"C¡lov  stˆna ud losti:");
  define(-1,5,150,250,12,0,label,"Popis akce:");
  define(-1,260,60,100,12,0,label,"Aplikuj na stˆnu:");
  define(50,200,60,50,10,0,input_line,10,1,16,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs((p->prim_anim & 0xf)+1));on_exit(test_int);
  define(60,200,75,50,10,0,input_line,10,1,16,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs((p->sec_anim & 0xf)+1));on_exit(test_int);
  define(70,200,90,50,10,0,input_line,10,0,499,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs(p->xsec<<1));on_exit(test_int);
  define(80,200,105,50,10,0,input_line,10,0,511,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs(p->ysec<<1));on_exit(test_int);
  define(90,200,120,50,10,0,input_line,10,0,65535,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs(p->sector_tag));on_exit(test_int);
  define(100,200,135,50,10,0,str_line,steny2);property(&b2,NULL,NULL,WINCOLOR);
   c_default(p->side_tag & 0x3);on_enter(string_list_sup);
  define(110,100,150,150,10,0,str_line,actions);property(&b2,NULL,NULL,WINCOLOR);
   on_enter(string_list_sup); c_default(p->action);
  define(120,10,175,150,10,0,check_box,side_flgs[0]);
  define(130,10,187,150,10,0,check_box,side_flgs[1]);
  define(140,10,199,150,10,0,check_box,side_flgs[2]);
  define(150,10,211,150,10,0,check_box,side_flgs[3]);
  define(160,10,223,150,10,0,check_box,side_flgs[4]);
  define(170,10,235,150,10,0,check_box,side_flgs[5]);
  define(180,10,247,150,10,0,check_box,side_flgs[6]);
  define(190,10,259,150,10,0,check_box,side_flgs[7]);
  define(200,190,175,100,10,0,check_box,side_flgs[8]);
  define(210,190,187,100,10,0,check_box,side_flgs[9]);
  define(220,190,199,100,10,0,check_box,side_flgs[10]);
  define(230,190,211,150,10,0,check_box,side_flgs[11]);
  define(240,190,223,150,10,0,check_box,side_flgs[12]);
  define(250,190,235,150,10,0,check_box,side_flgs[13]);
  define(260,190,247,150,10,0,check_box,side_flgs[14]);
  define(270,190,259,150,10,0,check_box,side_flgs[15]);
  define(280,10,271,75,10,0,check_box,side_flgs[16]);
  define(290,10,283,75,10,0,check_box,side_flgs[17]);
  define(300,190,271,150,10,0,check_box,side_flgs[18]);
  define(310,10,295,75,11,0,check_box,side_flgs[19]);
  define(400,290,80,100,10,0,check_box,"Severn¡");
  define(410,290,95,100,10,0,check_box,"V˜chodn¡");
  define(420,290,110,100,10,0,check_box,"Ji‘n¡");
  define(430,290,125,100,10,0,check_box,"Z padn¡");
  define(340,290,150,100,15,0,button2,"V¡ce >>");on_change(action_flags);
  define(350,290,150,100,15,0,value_store,4);c_default(p->flags & 0xfff00000);
  define(360,290,150,100,15,0,value_store,4);c_default(source);
  define(370,290,150,100,15,0,value_store,4);c_default(smer);
  define(-1,5,20,60,10,1,label,"Lclip:");
  define(440,30,35,30,12,1,input_line,3,0,255,"%3d");
   property(&b2,NULL,NULL,WINCOLOR);
  set_default(strs(p->lclip));on_exit(test_int);
  define(450,10,220,30,30,1,radio_butts,3,"-","\x4","\x6");c_default((p->oblouk>>5) & 0x3);
   property(NULL,icones,NULL,WINCOLOR);
  define(460,10,175,80,12,1,button,"V˜klenek");on_change(edit_vyklenek_start);
  define(470,190,283,150,10,0,check_box,"Lze polo‘it za");c_default(p->oblouk>>7);
  define(480,10,307,75,10,0,check_box,"P©edsunout s.");c_default(p->side_tag>>7);
  fill_bit_fields(0,120,p->flags,20); if (source)
  fill_bit_fields(0,400,1<<smer,4); else fill_bit_fields(0,400,0xf,4);
  set_enable(0,3400,source!=0);
  set_enable(0,460,source!=0);
  redraw_window();
  }