本文整理汇总了C++中StringToInt函数的典型用法代码示例。如果您正苦于以下问题:C++ StringToInt函数的具体用法?C++ StringToInt怎么用?C++ StringToInt使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StringToInt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StringToInt
/**
* Return the frequency as specified in the config file.
*/
int unsigned FtdiDmxPlugin::GetFrequency() {
unsigned int frequency;
if (!StringToInt(m_preferences->GetValue(K_FREQUENCY), &frequency))
StringToInt(DEFAULT_FREQUENCY, &frequency);
return frequency;
}
示例2: ParseFace
void ParseFace(const std::string& line, std::vector<Face>& faces)
{
Face face;
// First split by spaces
std::vector<std::string> tripletTokens = Tokenize(line, " \t");
// Skip first and process triplets
for (auto it = tripletTokens.cbegin() + 1; it != tripletTokens.cend(); ++it)
{
const auto token = *it;
IndexTriplet triplet;
// Split by slashes to indices
std::vector<std::string> intTokens = Tokenize(token, "/");
if (intTokens.size() == 3) // "pos/tex/nor"
{
triplet.positionIndex = StringToInt(intTokens[0]);
triplet.texcoordIndex = StringToInt(intTokens[1]);
triplet.normalIndex = StringToInt(intTokens[2]);
}
if (intTokens.size() == 2) // "pos//nor"
{
triplet.positionIndex = StringToInt(intTokens[0]);
triplet.normalIndex = StringToInt(intTokens[1]);
}
face.indices.push_back(triplet);
}
faces.push_back(face);
}
示例3: myml
MyML GameEngine::Draw()
{
MyML myml("T1;T2");
myml.E("T1").AddArray("Player");
for(int i=0;i<StringToInt(data.A("Team1.Player.size"));i++){
MyML& p=data.E("Team1.Player").E(IntToString(i));
MyML player("[email protected]|id;[email protected]|color;[email protected]|Pos",{p});
player.Do("[email protected]|Gui.OldPos",{p} );
myml.E("T1.Player").Type<MyMLArray>().Add(player);
}
for(int i=0;i<StringToInt(data.A("Team2.Player.size"));i++){
MyML& p=data.E("Team2.Player").E(IntToString(i));
MyML player("[email protected]|id;[email protected]|color;[email protected]|Pos",{p});
player.Do("Pos.x=null;Pos.y=null;");
player.E("Pos",invert(data.E("Team2.Player").E(STR(i)).E("Pos")));
player.E("Gui.OldPos",invert(data.E("Team2.Player").E(STR(i)).E("Gui.OldPos")));
myml.E("T1.Player").Type<MyMLArray>().Add(player);
}
myml.CpE(data,"Ball");
//cout<<myml.E("T1").E("Player").attributes["posy"]<<endl;
return myml;
}
示例4: StringToInt
void SPIDevice::PopulateSoftwareBackendOptions(
SoftwareBackend::Options *options) {
StringToInt(m_preferences->GetValue(PortCountKey()), &options->outputs);
StringToInt(m_preferences->GetValue(SyncPortKey()), &options->sync_output);
if (options->sync_output == -2) {
options->sync_output = options->outputs - 1;
}
}
示例5: VLOG
const net_call_out_rec* Callout::net_call_out_for(const std::string& node) const {
VLOG(2) << "Callout::net_call_out_for(" << node << ")";
if (starts_with(node, "20000:20000/")) {
auto s = node.substr(12);
s = s.substr(0, s.find('/'));
return net_call_out_for(StringToInt(s));
}
return net_call_out_for(StringToInt(node));
}
示例6: Open
static err_t Open(urlpart* p, const tchar_t* URL, int Flags)
{
err_t Result;
const tchar_t *String, *Equal;
tchar_t Value[MAXPATHFULL];
datetime_t Date = INVALID_DATETIME_T;
String = tcsrchr(URL,URLPART_SEP_CHAR);
if (!String)
return ERR_INVALID_DATA;
Clear(p);
Node_SetData((node*)p,STREAM_URL,TYPE_STRING,URL);
Equal = GetProtocol(URL,NULL,0,NULL);
tcsncpy_s(Value,TSIZEOF(Value),Equal,String-Equal);
tcsreplace(Value,TSIZEOF(Value),URLPART_SEP_ESCAPE,URLPART_SEPARATOR);
Node_SetData((node*)p,URLPART_URL,TYPE_STRING,Value);
while (String++ && *String)
{
Equal = tcschr(String,T('='));
if (Equal)
{
tchar_t *Sep = tcschr(Equal,T('#'));
if (Sep)
tcsncpy_s(Value,TSIZEOF(Value),Equal+1,Sep-Equal-1);
else
tcscpy_s(Value,TSIZEOF(Value),Equal+1);
if (tcsncmp(String,T("ofs"),Equal-String)==0)
p->Pos = StringToInt(Value,0);
else if (tcsncmp(String,T("len"),Equal-String)==0)
p->Length = StringToInt(Value,0);
else if (tcsncmp(String,T("mime"),Equal-String)==0)
Node_SetData((node*)p,URLPART_MIME,TYPE_STRING,Value);
else if (tcsncmp(String,T("date"),Equal-String)==0)
Date = StringToInt(Value,0);
}
String = tcschr(String,'#');
}
if (Date!=INVALID_DATETIME_T && Date != FileDateTime(Node_Context(p),Node_GetDataStr((node*)p,URLPART_URL)))
return ERR_INVALID_DATA;
p->Input = GetStream(p,Node_GetDataStr((node*)p,URLPART_URL),Flags);
if (!p->Input)
return ERR_NOT_SUPPORTED;
Stream_Blocking(p->Input,p->Blocking);
Result = Stream_Open(p->Input,Node_GetDataStr((node*)p,URLPART_URL),Flags);
if (Result == ERR_NONE && p->Pos!=INVALID_FILEPOS_T) // TODO: support asynchronous stream opening
{
if (Stream_Seek(p->Input,p->Pos,SEEK_SET)!=p->Pos)
return ERR_INVALID_DATA;
}
return Result;
}
示例7: ParseTokens
int ParseTokens(const char* left, const char* right)
{
int left_int = StringToInt(left);
char* tmp = strchr(right, '|');
if(tmp == NULL)
return (left_int | StringToInt(right));
tmp[0] = '\0';
tmp++;
return (left_int | ParseTokens(right, tmp));
}
示例8: ParserAttribInt
int ParserAttribInt(parser* p)
{
tchar_t Token[MAXTOKEN];
if (!ParserAttribString(p,Token,MAXTOKEN))
return 0;
if (Token[0]=='0' && Token[1]=='x')
return StringToInt(Token+2,1);
else
return StringToInt(Token,0);
}
示例9: proccess_rx
void proccess_rx(void){
uint32_t u, i;
switch(rx_buffer[0]){
case 'g':
u = Actual_U;
i = Actual_I;
USART_SendString(USART6, "U:");
USART_SendNumber(USART6, u);
USART_SendString(USART6, ", I:");
USART_SendNumber(USART6, i);
USART_SendString(USART6, "\n");
break;
case 's':
if(rx_pointer>1){
u = StringToInt(rx_buffer+1, 5);
i = StringToInt(rx_buffer+6, 5);
Set_U = u;
Set_I = i;
USART_SendString(USART6, "OK\n");
}else{
u = Set_U;
i = Set_I;
USART_SendString(USART6, "Set U:");
USART_SendNumber(USART6, u);
USART_SendString(USART6, ", Set I:");
USART_SendNumber(USART6, i);
USART_SendString(USART6, "\n");
}
break;
case 'o':
if(rx_pointer>1){
output = (rx_buffer[1]=='1');
}
USART_SendString(USART6, output?"Output ON\n":"Output OFF\n");
break;
case 'q':
GPIO_SetBits(GPIOC, GPIO_Pin_0);
USART_SendString(USART6, "PC0 ON\n");
break;
case 'a':
GPIO_ResetBits(GPIOC, GPIO_Pin_0);
USART_SendString(USART6, "PC0 OFF\n");
break;
default:
USART_SendString(USART6, "Unknown command\n");
break;
}
}
示例10: StringToInt
void convert_sl::Get_Date_Int(string date, int &year, int &month, int &day)
{
year = StringToInt(date.substr(0,4));
month = StringToInt(date.substr(4,2));
day = StringToInt(date.substr(6,2));
// divide date string to year, month, and day string
//string y(date.c_str(),0,4);
//string m(date.c_str(),4,2);
//string d(date.c_str(),6,2);
//// convert to integer
//sscanf(y.c_str(),"%d",&year);
//sscanf(m.c_str(),"%d",&month);
//sscanf(d.c_str(),"%d",&day);
}
示例11: areamask
Announce::Announce(string _areamask, string _msgbase, string _msg_from,
string _aka, string _msg_to, string _msg_subject,
string _templ, string _origin) : areamask(), msgbase(), msg_from(_msg_from),
aka(_aka), msg_to(_msg_to), msg_subject(_msg_subject), templ(_templ),
origin(_origin), local(false) {
vector<string> v;
SplitLine(_areamask, (*this).areamask, ',');
SplitLine(_msgbase, v, ':');
(*this).msgbase.first = StringToInt(v[0]);
(*this).msgbase.second = StringToInt(v[1]);
if((*this).aka.isEmpty()) {
(*this).local = true;
}
}
示例12: Trim
void SMLoader::LoadFromTokens(
RString sStepsType,
RString sDescription,
RString sDifficulty,
RString sMeter,
RString sRadarValues,
RString sNoteData,
Steps &out
)
{
// we're loading from disk, so this is by definition already saved:
out.SetSavedToDisk( true );
Trim( sStepsType );
Trim( sDescription );
Trim( sDifficulty );
Trim( sNoteData );
// LOG->Trace( "Steps::LoadFromTokens()" );
// backwards compatibility hacks:
// HACK: We eliminated "ez2-single-hard", but we should still handle it.
if( sStepsType == "ez2-single-hard" )
sStepsType = "ez2-single";
// HACK: "para-single" used to be called just "para"
if( sStepsType == "para" )
sStepsType = "para-single";
out.m_StepsType = GAMEMAN->StringToStepsType( sStepsType );
out.SetDescription( sDescription );
out.SetCredit( sDescription ); // this is often used for both.
out.SetChartName(sDescription); // yeah, one more for good measure.
out.SetDifficulty( OldStyleStringToDifficulty(sDifficulty) );
// Handle hacks that originated back when StepMania didn't have
// Difficulty_Challenge. (At least v1.64, possibly v3.0 final...)
if( out.GetDifficulty() == Difficulty_Hard )
{
// HACK: SMANIAC used to be Difficulty_Hard with a special description.
if( sDescription.CompareNoCase("smaniac") == 0 )
out.SetDifficulty( Difficulty_Challenge );
// HACK: CHALLENGE used to be Difficulty_Hard with a special description.
if( sDescription.CompareNoCase("challenge") == 0 )
out.SetDifficulty( Difficulty_Challenge );
}
if( sMeter.empty() )
{
// some simfiles (e.g. X-SPECIALs from Zenius-I-Vanisher) don't
// have a meter on certain steps. Make the meter 1 in these instances.
sMeter = "1";
}
out.SetMeter( StringToInt(sMeter) );
out.SetSMNoteData( sNoteData );
out.TidyUpData();
}
示例13: L_WRN
TError TContainerHolder::RestoreId(const kv::TNode &node, int &id) {
std::string value = "";
TError error = Storage->Get(node, P_RAW_ID, value);
if (error) {
// FIXME before v1.0 we didn't store id for meta or stopped containers;
// don't try to recover, just assign new safe one
error = IdMap.Get(id);
if (error)
return error;
L_WRN() << "Couldn't restore container id, using " << id << std::endl;
} else {
error = StringToInt(value, id);
if (error)
return error;
error = IdMap.GetAt(id);
if (error) {
// FIXME before v1.0 there was a possibility for two containers
// to use the same id, allocate new one upon restore we see this
error = IdMap.Get(id);
if (error)
return error;
L_WRN() << "Container ids clashed, using new " << id << std::endl;
}
return error;
}
return TError::Success();
}
示例14: StringToInt
void isColorPickerDlg::OnEnterComponentText(wxSlider * slider, wxTextCtrl * text)
{
int ret = StringToInt(text->GetValue());
if (ret>255 ) ret = 255; if (ret < 0) ret = 0;
slider->SetValue(ret);
RefreshColor();
}
示例15: main
int main(int argc, char* argv[])
{
int upperBound = DEFAULT_UPPER_BOUND;
int userUpperBound = 0; //user can set by first command line parameter
if (argc > 1)
{
bool errors;
userUpperBound = StringToInt(argv[1], errors);
if (errors)
{
printf("Invalid argument!");
return 1;
}
if (userUpperBound > LOWER_BOUND)
{
upperBound = userUpperBound;
}
}
PrintSpecialNumbers(upperBound);
return 0;
}