Example #1
0
cocos2d::Label* NodeCom::initLabel(rapidjson::Value& value)
{
    if (value.IsNull()||!value.HasMember("font")) {
        return nullptr;
    }
    
    auto local=GX::Localization::getInstance();
    
    std::string text=value.HasMember("text")?
        local->getStr(value["text"].GetString()).c_str():"";
    std::string font=local->getStr(value["font"].GetString()).c_str();
    cocos2d::Value s(GX::Localization::getInstance()->getStr(value["fontSize"].GetString()));
    int size=s.asInt();
    
    cocos2d::Label* label=cocos2d::Label::createWithTTF(text, font, size);
    
    if (value.HasMember("fontColor")) {
        label->setTextColor(Color4BFromString(value["fontColor"].GetString()));
    }
    
    if (value.HasMember("textVAlignment")) {
        const char* str=value["textVAlignment"].GetString();
        if (strcmp("top", str)==0) {
            label->setVerticalAlignment(cocos2d::TextVAlignment::TOP);
        }
        else if(strcmp("center", str)==0){
            label->setVerticalAlignment(cocos2d::TextVAlignment::CENTER);
        }
        else if(strcmp("bottom", str)==0){
            label->setVerticalAlignment(cocos2d::TextVAlignment::BOTTOM);
        }
    }
    
    if (value.HasMember("textHAlignment")) {
        const char* str=value["textHAlignment"].GetString();
        if (strcmp("left", str)==0) {
            label->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT);
        }
        else if(strcmp("center", str)==0){
            label->setHorizontalAlignment(cocos2d::TextHAlignment::CENTER);
        }
        else if(strcmp("right", str)==0){
            label->setHorizontalAlignment(cocos2d::TextHAlignment::RIGHT);
        }
    }

    return label;
}
Example #2
0
int TdApi::reqCombActionInsert(dict req, int nRequestID)
{
	CThostFtdcInputCombActionField myreq = CThostFtdcInputCombActionField();
	memset(&myreq, 0, sizeof(myreq));
	getStr(req, "InstrumentID", myreq.InstrumentID);
	getChar(req, "Direction", &myreq.Direction);
	getStr(req, "CombActionRef", myreq.CombActionRef);
	getChar(req, "HedgeFlag", &myreq.HedgeFlag);
	getStr(req, "UserID", myreq.UserID);
	getInt(req, "Volume", &myreq.Volume);
	getStr(req, "InvestorID", myreq.InvestorID);
	getStr(req, "BrokerID", myreq.BrokerID);
	getChar(req, "CombDirection", &myreq.CombDirection);
	int i = this->api->ReqCombActionInsert(&myreq, nRequestID);
	return i;
};
Example #3
0
void cCsvSink::fetchConfig()
{
  cDataSink::fetchConfig();
  
  filename = getStr("filename");
  SMILE_IDBG(3,"filename = '%s'",filename);

  delimChar = getChar("delimChar");
  SMILE_IDBG(3,"delim = '%c'",delimChar);

  lag = getInt("lag");
  SMILE_IDBG(3,"lag = %i",lag);

  append = getInt("append");
  if (append) { SMILE_IDBG(3,"append to file is enabled"); }

  printHeader = getInt("printHeader");
  if (printHeader) { SMILE_IDBG(3,"printing header with feature names"); }

  number = getInt("number");
  if (number) { SMILE_IDBG(3,"printing of frameIndex (number) to file is enabled"); }

  timestamp = getInt("timestamp");
  if (timestamp) { SMILE_IDBG(3,"printing timestamp attribute (index 1) enabled"); }

/*
  instanceBase = getStr("instanceBase");
  SMILE_DBG(3,"instanceBase = '%s'",instanceBase);

  instanceName = getStr("instanceName");
  SMILE_DBG(3,"instanceName = '%s'",instanceName);
*/


}
Example #4
0
static int
handlerDisplayStock(void *packetPtr, size_t packetSize)
{
  int			i;
  int			user = NOBODY;
  char			msg[256] = {0};
  char			*password = NULL;

  password = getStr(&packetPtr, &packetSize);
  if ((user = checkPassword(password)) == USER || user == ADMIN) {
    snprintf(msg, sizeof(msg), "Money : %d\n", money);
    sendLogMessage(msg);
    sendLogMessage("\nIngredient stock\n================\n");
    for (i = 0; stock[i].name; ++i) {
      snprintf(msg, sizeof(msg), "[%d] - %s\n", stock[i].quantity, stock[i].name);
      sendLogMessage(msg);
    }
    sendLogMessage("\nFor sale\n========\n");
    for (i = 0; tab_recipes[i].name; ++i) {
      if (tab_recipes[i].quantity) {
	snprintf(msg, sizeof(msg), "%d x %s\n", tab_recipes[i].quantity, tab_recipes[i].name);
	sendLogMessage(msg);
      }
    }
  }
  free(password);
  return 0;
}
Example #5
0
void  getSubStr( char *str, char *substr, int start, int end )  
{  
	int substrlen = end - start + 1;
    	start = startposizition( str, start );  
    	end   = endposizition( str, end );  
	getStr( str, substr, substrlen, start, end );     
}  
Example #6
0
 Variant getValue(ElmT elm) const {
   if (isInt(elm)) {
     return getInt(elm);
   }
   assert(isStr(elm));
   return getStr(elm);
 }
Example #7
0
uint64_t TraderApi::insertOrder(dict req, uint64_t sessionid)
{
	XTPOrderInsertInfo myreq = XTPOrderInsertInfo();
	memset(&myreq, 0, sizeof(myreq));
	getDouble(req, "stop_price", &myreq.stop_price);
	getDouble(req, "price", &myreq.price);
	getStr(req, "ticker", myreq.ticker);

	getUint32(req, "order_client_id", &myreq.order_client_id);
	getUint64(req, "order_xtp_id", &myreq.order_xtp_id);
	getInt64(req, "quantity", &myreq.quantity);

	int price_type;
	int side;
	int market;
	int business_type;
	getInt(req, "price_type", &price_type);
	getInt(req, "side", &side);
	getInt(req, "market", &market);
	getInt(req, "business_type", &business_type);
	myreq.price_type = (XTP_PRICE_TYPE)price_type;
	myreq.side = (XTP_SIDE_TYPE)side;
	myreq.market = (XTP_MARKET_TYPE)market;
	myreq.business_type = (XTP_BUSINESS_TYPE)business_type;

	return this->api->InsertOrder(&myreq, sessionid);
};
 Variant getValue(ElmT elm) const {
   if (isInt(elm)) {
     return getInt(elm);
   }
   ASSERT(isStr(elm));
   return getStr(elm);
 }
Example #9
0
 bool isHappy(int n) {
     if (n <= 0)
     {
         return false;
     }
     
     string numStr = "";
     int i = 0;
     int temp = 0;
     int len = 0;
     while((len = getStr(numStr, n)) > 1)
     {
         n = 0;
         for (i = 0; i < len; i++)
         {
             temp = numStr[i] - '0';
             n += temp * temp;
         }
     }
     
     if (len == 1 && (numStr[0] == '1' || numStr[0] == '7'))
     {
         return true;
     }
     
     return false;
 }
Example #10
0
/* a show function,nothing */
void showSword(void)
{
	char num[4];
	int n;

	puts("So what sword do you want to show?");
	getStr(num,4);
	n = atoi(num);
	if(n<0 || n>=100)
	{
		puts("It seem you are not enter a right id.");
		return;
	}

	if(Swords[n] == 0)
	{
		puts("It seems the the sword is not on sele");
		return;
	}

	puts("================== Swords ==================");
	printf("name:    %s\n",Swords[n]->name);
	printf("damage:  %d\n",Swords[n]->damage);
	printf("cost:    %d\n",Swords[n]->cost);
	printf("profile: %s\n",Swords[n]->profile);
	puts("==================  END   ==================\n");

}
Example #11
0
/* get sword's id and free it 
 * no changce to double free
 * */
void deleteSword(void)
{
	char num[4];
	int n;
	puts("Now give me the id of sword you don't want to sale.");
	getStr(num,4);
	n = atoi(num);
	if(n<0 || n>=100)
	{
		puts("It seem you are not enter a right id.");
		return;
	}

	if(Swords[n] == 0)
	{
		puts("It seems the the sword is not on sele");
		return;
	}
	free(Swords[n]->profile);
	free(Swords[n]);
	Swords[n] = 0;
	puts("Delete success\n");


}
Example #12
0
int String::compare(const char* cb, size_t n) const
{
    size_t  thisLen  = length();
    int  res;

    //
    // preconditions
    //

    if(cb == 0)
        strError("String::compare", "InvalidArgument");

    //
    // operations
    //

    if(n == NPOS)
        n = strlen(cb);

    res = memcmp(getStr(), cb, thisLen > n ? n : thisLen);
    if(res == 0 && n != thisLen) {
        if(thisLen > n)
            res = 1;
        else
            res = -1;
    }
    return res;
}
Example #13
0
int
main(int argc, char *argv[])
{
	printf("%d\n", getInt());
	printf(" ----- %s ------\n", getStr());
	printf(" -/-/- %s -/-/-/\n", getArray());
}
Example #14
0
parsing_result_type_t parseSync(xmlNode * node, CONTEXT * ctx)
{
    ctx->sync_manager = calloc(1, sizeof(EC_SYNC_MANAGER));
    EC_SYNC_MANAGER *sm = ctx->sync_manager;
    char parseBuffer[20];
    char *direction = parseBuffer;
    int parsingIsOkay = 1;
    parsingIsOkay = getStr(node, "dir", &direction);
    if (strcasecmp("outputs", direction) == 0)
    {
      sm->direction = PARSER_DIR_OUTPUT;
    }
    else if (strcasecmp("inputs", direction) == 0)
    {
      sm->direction = PARSER_DIR_INPUT;
    }
    else
    {
      sm->direction = PARSER_DIR_INVALID;
    }
    parsingIsOkay =parsingIsOkay &&
        getInt(node, "index", &sm->index, PARSER_REQUIRED) &&
        getInt(node, "watchdog", &sm->watchdog, PARSER_REQUIRED) &&
        parseChildren(node, ctx, "pdo", parsePdo) &&
        (sm->parent = ctx->device_type);
    if (parsingIsOkay)
    {
        if (sm->direction == PARSER_DIR_INVALID)
            return PARSING_OKAY;
        return ellAddOK(&ctx->device_type->sync_managers, &sm->node);
    }
    else
        return PARSING_ERROR;
}
void getData(char *buf, int *nNum, int num[], int *nStr, char str[][20])
{
	int k;
	k = 0;

	
	while((buf[k] != '\0') && (buf[k] != '\n'))
	{
		while(buf[k] == ' ' || buf[k] == '\t')
		(k)++;
		
		if(isdigit(buf[k]) || buf[k] == '-')
			/* 填写调用getNum函数,获取整型数的语句		*/
		{
			getNum( buf, k, num );
			*nNum += 1;
			num[*nNum + 1] = *num;
		}

		if(isalpha(buf[k]))
			/* 填写调用getStr函数,获取字符串的语句		*/
		{
			getStr( buf, k, *str );
			*nStr += 1;
			strcpy(str[*nStr+1],*str);
		}
		while(buf[k] != ' ' && buf[k] != '\t' && buf[k] != '\0' && buf[k] != '\n')
			(k)++;
	}
}
Example #16
0
int TdApi::reqQryNotice(dict req, int nRequestID)
{
	CThostFtdcQryNoticeField myreq = CThostFtdcQryNoticeField();
	memset(&myreq, 0, sizeof(myreq));
	getStr(req, "BrokerID", myreq.BrokerID);
	int i = this->api->ReqQryNotice(&myreq, nRequestID);
	return i;
};
Example #17
0
int MdApi::reqUserLogin(dict req, int nRequestID)
{
	CThostFtdcReqUserLoginField myreq = CThostFtdcReqUserLoginField();
	memset(&myreq, 0, sizeof(myreq));
	getStr(req, "MacAddress", myreq.MacAddress);
	getStr(req, "UserProductInfo", myreq.UserProductInfo);
	getStr(req, "UserID", myreq.UserID);
	getStr(req, "TradingDay", myreq.TradingDay);
	getStr(req, "InterfaceProductInfo", myreq.InterfaceProductInfo);
	getStr(req, "BrokerID", myreq.BrokerID);
	getStr(req, "ClientIPAddress", myreq.ClientIPAddress);
	getStr(req, "OneTimePassword", myreq.OneTimePassword);
	getStr(req, "ProtocolInfo", myreq.ProtocolInfo);
	getStr(req, "Password", myreq.Password);
	int i = this->api->ReqUserLogin(&myreq, nRequestID);
	return i;
};
Example #18
0
int TdApi::reqQryExchange(dict req, int nRequestID)
{
	CThostFtdcQryExchangeField myreq = CThostFtdcQryExchangeField();
	memset(&myreq, 0, sizeof(myreq));
	getStr(req, "ExchangeID", myreq.ExchangeID);
	int i = this->api->ReqQryExchange(&myreq, nRequestID);
	return i;
};
Example #19
0
int TdApi::reqQryProductExchRate(dict req, int nRequestID)
{
	CThostFtdcQryProductExchRateField myreq = CThostFtdcQryProductExchRateField();
	memset(&myreq, 0, sizeof(myreq));
	getStr(req, "ProductID", myreq.ProductID);
	int i = this->api->ReqQryProductExchRate(&myreq, nRequestID);
	return i;
};
Example #20
0
int TdApi::reqQrySGEDeferRate(dict req, int nRequestID)
{
	CQdpFtdcQrySGEDeferRateField myreq = CQdpFtdcQrySGEDeferRateField();
	memset(&myreq, 0, sizeof(myreq));
	getStr(req, "InstrumentID", myreq.InstrumentID);
	int i = this->api->ReqQrySGEDeferRate(&myreq, nRequestID);
	return i;
};
Example #21
0
int TdApi::reqQryDepthMarketData(dict req, int nRequestID)
{
	CThostFtdcQryDepthMarketDataField myreq = CThostFtdcQryDepthMarketDataField();
	memset(&myreq, 0, sizeof(myreq));
	getStr(req, "InstrumentID", myreq.InstrumentID);
	int i = this->api->ReqQryDepthMarketData(&myreq, nRequestID);
	return i;
};
Example #22
0
MainMenu::MainMenu() : eListBoxWindow<eListBoxEntryText>( getStr( strMainMenuTitle ), MENU_NO_ITEMS + 3, MENU_WIDTH, false )
{
        for ( int i = 1; i <= MENU_NO_ITEMS; i++ ) {
                if ( 
			( i == MENU_ITEM_EDIT_INPUTS ) ||
			( i == MENU_ITEM_RESET ) ||
			( i == MENU_ITEM_ABOUT )
		)
                        new eListBoxEntryTextSeparator((&(list)), getNamedPixmapP( "listbox.separator" ), 0, true );

                new eListBoxEntryText( &list, getStr( strMainMenuItemFirst + i - 1 ), (void*)i);
        }

        move( ePoint( MENU_TOPLEFTX, MENU_TOPLEFTY ) );

        CONNECT( list.selected, MainMenu::listSelected );
}
Example #23
0
int printStr_4lua(lua_State *L)
{
	int y = getNumber(L);
	int x = getNumber(L);	
	
	printStr( (char *)getStr(L), x, y );
	return 0;
}
Example #24
0
char *parseRE(ControlStruct *p, const char *pStr)
{
   int x, err;
   char tmpBuf[20], *cp, *cp1, *rv;
   char portStr[80], devcStr[80], errBuf[80];

   strcpy(portStr, ".*");
   strcpy(devcStr, ".*");
   cp = (char*)pStr;
   for (;;)
   {
      strcpy(tmpBuf, "");
      for (rv = cp; *cp && isspace(*cp); cp++);
      rv = cp;
      for (x = 0, cp1 = tmpBuf; *cp != '\0' && !isspace(*cp) && x < 20; x++)
      {
         *(cp1++) = tolower(*cp++);
         *cp1 = '\0';
      }
      if (strcmp(tmpBuf, "port") == 0)
         cp = getStr(portStr, cp);
      else if (strcmp(tmpBuf, "device") == 0)
         cp = getStr(devcStr, cp);
      else
      {
         break;
      }
   }
   if (dbg) syslog(LOG_DEBUG, "parseRE():have portStr of |%s|, |%s|", portStr, rv);
   if (dbg) syslog(LOG_DEBUG, "parseRE():have devcStr of |%s|, |%s|", devcStr, rv);
   if ((err = regcomp(&p->portRE, portStr, REG_NOSUB)) != 0)
   {
      regerror(err, &p->portRE, errBuf, sizeof(errBuf));
      fprintf(p->fp, "Err:%s in port RE\n", errBuf);
      rv = NULL;
   }
   if ((err = regcomp(&p->devcRE, devcStr, REG_NOSUB)) != 0)
   {
      regerror(err, &p->devcRE, errBuf, sizeof(errBuf));
      fprintf(p->fp, "Err:%s in Device RE\n", errBuf);
      rv = NULL;
   }
   if (dbg) syslog(LOG_DEBUG, "parseRE():returning with |%s|", rv);
   return(rv);
}
Example #25
0
CNESCsvResult::CNESCsvResult(const ToolConfiguration & tc, types::String * conf, const std::wstring & id, const std::wstring & _path) : tct(tc.getToolConfiguration()), current(nullptr), path(_path)
{
    std::string projectName;
    std::string projectVersion;
    std::string projectAuthor;
    if (conf)
    {
        if (conf->getSize() >= 4)
        {
            projectName = getStr(conf->get(3));
        }
        if (conf->getSize() >= 5)
        {
            projectVersion = getStr(conf->get(4));
        }
        if (conf->getSize() >= 6)
        {
            projectAuthor = getStr(conf->get(5));
        }
    }
    const std::wstring fullpath = SLint::getFullPath(path);
    out = new std::ofstream(scilab::UTF8::toUTF8(fullpath), std::ios::out);
    if (!out->is_open())
    {
        delete out;
        out = nullptr;
        throw slint::FileException(fullpath, _("Cannot open the file"));
    }
    else
    {
        (*out) << projectName << ',';
        (*out) << projectVersion << ',';
        (*out) << projectAuthor << ',';
        (*out) << "scilab,";

        std::chrono::time_point<std::chrono::system_clock> point = std::chrono::system_clock::now();;
        std::time_t time = std::chrono::system_clock::to_time_t(point);
        std::string date(std::ctime(&time));
        if (date.back() == '\n')
        {
            date = std::string(date.begin(), std::prev(date.end()));
        }
        (*out) << getStr(date) << ",\n";
    }
}
Example #26
0
int getNCharsPrompt_4lua(lua_State *L)
{
	char *str = (char *)getStr(L);
	int n = getNumber(L);

	putStr(L, getNCharsPrompt(n, str));
	
	return 1;
}
Example #27
0
int TraderApi::queryTrades(dict req, uint64_t sessionid, int reqid)
{
	XTPQueryTraderReq myreq = XTPQueryTraderReq();
	memset(&myreq, 0, sizeof(myreq));
	getStr(req, "ticker", myreq.ticker);
	getInt64(req, "end_time", &myreq.end_time);
	getInt64(req, "begin_time", &myreq.begin_time);
	return this->api->QueryTrades(&myreq, sessionid, reqid);
};
Example #28
0
int main(void)
{
  char *space_ptr, *second_arg;
  size_t index;

//  mapMem((void *)0xB8000, (void *)0xB8000, 8, 0);
//  dev_num = lookupName( dev_name, strlen(dev_name) );

//  parseDevice(dev_name, &dev_num);

  dev_num = 0xA00;

  charBuf = malloc(BUF_LEN);
  currDir = malloc(PATH_LEN);

  if( charBuf == NULL || currDir == NULL )
    return -1;

  currDir[0] = '/';
  currDir[1] = '\0';

  if( mountFs(dev_num, "fat",3, "/", 35) != 0 )
    print("Mount failed\n");

//  if( unmountFs("/devices/ramdisk0") == 0 )
//    printf("Unmounted\n");

  while( true )
  {
    printf("%s:%.*s>", dev_name, PATH_LEN, currDir);
    fflush(stdout);

    index = getStr(charBuf, BUF_LEN);

    charBuf[index] = 0;

    if( (space_ptr = strpbrk( charBuf, " \n" )) == NULL )
    {
      printf("\nCommand is too long - ignoring...\n");
      continue;
    }

    if( index == 0 )
    {
      printf("Strange error (index is 0?!)...\n");
      continue;
    }

    charBuf[index-1] = '\0';

    second_arg = *space_ptr ? space_ptr + 1 : NULL;
int stat;
    if( (stat=doCommand( charBuf, index, second_arg )) != 0 )
      printf("Error: Bad command or argument. %d\n", stat);
  }
  return 1;
}
Example #29
0
MainMenuFeatured::MainMenuFeatured( int currentViewNo ) : eListBoxWindow<eListBoxEntryText>( getStr( strMainMenuItemViewFeat ), MENU_F_NOITEMS, MENU_F_WIDTH, false )
{
        for ( int i = 1; i <= MENU_F_NOITEMS; i++ )
		new eListBoxEntryText( &list, getStr( strFeaturedMenuFirst + i - 1 ), (void*)i);

        move( ePoint( MENU_F_TOPLEFTX, MENU_F_TOPLEFTY ) );

        CONNECT( list.selected, MainMenuFeatured::listSelected );
}
Example #30
0
int main() {
    char inputStr[100] = {};
    char searchedStr[100] = {};
    int position = 0;
    int inputStrLen = INIT_INSTR_LEN, searchedStrLen = INIT_SERSTR_LEN;
    /*  Get the string */
    inputStrLen =  getStr(inputStr, inputStrLen);
    searchedStrLen = getStr(searchedStr, searchedStrLen);
    
    /*  Search the string */
    position = searchd(inputStr, searchedStr, inputStrLen, searchedStrLen);
    
    /*  Output */
    printf("%d\n", position);
    
    /*  End */
    return 0;
}