本文整理汇总了C++中STR_String类的典型用法代码示例。如果您正苦于以下问题:C++ STR_String类的具体用法?C++ STR_String怎么用?C++ STR_String使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了STR_String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DetermineProgress
void GPC_Engine::UpdateLoadingAnimation(void)
{
//int delta;
float progress = DetermineProgress();
if(progress > m_previousProgress)
{
// delta = progress - m_previousProgress;
m_previousProgress = progress;
if(m_previousProgress > 1.0)
m_previousProgress = 1.0; // limit to 1.0 (has to change !)
// m_engine->m_previousProgress = 0.0;
}
STR_String to = "";
STR_String from = "";
STR_String subject = "progress";
STR_String body;
body.Format("%f", progress); // a number between 0.0 and 1.0
if(m_networkdev)
{
// Store a progress message in the network device.
NG_NetworkMessage* msg = new NG_NetworkMessage(to, from, subject, body);
m_networkdev->SendNetworkMessage(msg);
msg->Release();
}
}
示例2:
vector<NG_NetworkMessage*> NG_NetworkScene::FindMessages(
const STR_String& to,
const STR_String& from,
const STR_String& subject,
bool spamallowed)
{
vector<NG_NetworkMessage*> foundmessages;
bool notfound = false;
// broad phase
notfound = ((to.IsEmpty() || spamallowed) ? notfound : m_messagesByDestinationName[to] == NULL);
if (!notfound)
notfound = (from.IsEmpty() ? notfound : m_messagesBySenderName[from] == NULL);
if (!notfound)
notfound = (subject.IsEmpty() ? notfound : m_messagesBySubject[subject] == NULL);
if (notfound) {
// it's definitely NOT in the scene, so stop looking
} else { // narrow phase
// possibly it's there, but maybe not (false hit)
if (to.IsEmpty()) {
// take all messages, and check other fields
MT_assert(!"objectnames that are empty are not valid, so make it a hobby project :)\n");
} else {
//todo: find intersection of messages (that are in other 2 maps)
vector<NG_NetworkMessage*>** tolistptr = m_messagesByDestinationName[to];
if (tolistptr) {
vector<NG_NetworkMessage*>* tolist = *tolistptr;
vector<NG_NetworkMessage*>::iterator listit;
for (listit=tolist->begin();!(listit==tolist->end());listit++) {
NG_NetworkMessage* message = *listit;
if (ConstraintsAreValid(from, subject, message)) {
message->AddRef();
foundmessages.push_back(message);
}
}
}
// TODO find intersection of messages (that are in other 2 maps)
if (spamallowed) {
tolistptr = m_messagesByDestinationName[""];
if (tolistptr) {
vector<NG_NetworkMessage*>* tolist = *tolistptr;
vector<NG_NetworkMessage*>::iterator listit;
for (listit=tolist->begin();!(listit==tolist->end());listit++) {
NG_NetworkMessage* message = *listit;
if (ConstraintsAreValid(from, subject, message)) {
message->AddRef();
foundmessages.push_back(message);
}
}
}
}
}
}
return foundmessages;
}
示例3: GPG_PyNextFrame
static int GPG_PyNextFrame(void *state0)
{
GPG_NextFrameState *state = (GPG_NextFrameState *) state0;
int exitcode;
STR_String exitstring;
bool run = GPG_NextFrame(state->system, state->app, exitcode, exitstring, state->gs);
if (run) return 0;
else {
if (exitcode)
fprintf(stderr, "Exit code %d: %s\n", exitcode, exitstring.ReadPtr());
return 1;
}
}
示例4: Term
void CParser::Term(int s)
{
// generates an error if the next symbol isn't the specified symbol s
// otherwise, skip the symbol
if (s == sym) NextSym();
else {
STR_String msg;
msg.Format("Warning: " + Symbol2Str(s) + " expected\ncontinuing without it");
// AfxMessageBox(msg,MB_ICONERROR);
trace(msg);
}
}
示例5: GHOST_GetTitle
char* GHOST_GetTitle(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
STR_String title;
window->getTitle(title);
char *ctitle = (char*) malloc(title.Length() + 1);
if (ctitle == NULL) return NULL;
strcpy(ctitle, title.Ptr());
return ctitle;
}
示例6: NextCh
void CParser::TermChar(char c)
{
// generates an error if the next char isn't the specified char c,
// otherwise, skip the char
if (ch == c)
{
NextCh();
}
else
{
STR_String str;
str.Format("Warning: %c expected\ncontinuing without it", c);
trace(str);
}
}
示例7: PyGetTextureName
PyObject* KX_MeshProxy::PyGetTextureName(PyObject* args, PyObject* kwds)
{
int matid= 1;
STR_String matname;
if (PyArg_ParseTuple(args,"i:getTextureName",&matid))
{
matname = m_meshobj->GetTextureName(matid);
}
else {
return NULL;
}
return PyUnicode_FromString(matname.Ptr());
}
示例8: ConstraintsAreValid
bool NG_NetworkScene::ConstraintsAreValid(
const STR_String& from,
const STR_String& subject,
NG_NetworkMessage* message)
{
vector<NG_NetworkMessage*>** fromlistptr = m_messagesBySenderName[from];
vector<NG_NetworkMessage*>** subjectlistptr = m_messagesBySubject[subject];
vector<NG_NetworkMessage*>* fromlist = (fromlistptr ? *fromlistptr : NULL);
vector<NG_NetworkMessage*>* subjectlist = (subjectlistptr ? *subjectlistptr : NULL);
return (
( from.IsEmpty() || (!fromlist ? false : (!(std::find(fromlist->begin(), fromlist->end(), message) == fromlist->end())))
) &&
( subject.IsEmpty() || (!subjectlist ? false : (!(std::find(subjectlist->begin(), subjectlist->end(), message) == subjectlist->end())))
));
}
示例9: GetParent
void SCA_KeyboardSensor::AddToTargetProp(int keyIndex)
{
if (IsPrintable(keyIndex)) {
CValue* tprop = GetParent()->GetProperty(m_targetprop);
if (tprop) {
/* overwrite the old property */
if (IsDelete(keyIndex)) {
/* strip one char, if possible */
STR_String newprop = tprop->GetText();
int oldlength = newprop.Length();
if (oldlength >= 1 ) {
int newlength=oldlength;
BLI_str_cursor_step_prev_utf8(newprop, newprop.Length(), &newlength);
newprop.SetLength(newlength);
CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
GetParent()->SetProperty(m_targetprop, newstringprop);
newstringprop->Release();
}
} else {
/* append */
char pchar = ToCharacter(keyIndex, IsShifted());
STR_String newprop = tprop->GetText() + pchar;
CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
GetParent()->SetProperty(m_targetprop, newstringprop);
newstringprop->Release();
}
} else {
if (!IsDelete(keyIndex)) {
/* Make a new property. Deletes can be ignored. */
char pchar = ToCharacter(keyIndex, IsShifted());
STR_String newprop = pchar;
CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
GetParent()->SetProperty(m_targetprop, newstringprop);
newstringprop->Release();
}
}
}
}
示例10: split_string
static std::vector<STR_String> split_string(STR_String str)
{
std::vector<STR_String> text = std::vector<STR_String>();
/* Split the string upon new lines */
int begin=0, end=0;
while (end < str.Length())
{
if (str.GetAt(end) == '\n')
{
text.push_back(str.Mid(begin, end-begin));
begin = end+1;
}
end++;
}
//Now grab the last line
text.push_back(str.Mid(begin, end-begin));
return text;
}
示例11: AssembleMessage
STR_String * MSG_Message :: AssembleMessage( )
{
// Assemble with existing message string
STR_String * messageString = new STR_String( idMessage ) ;
if ( memcmp( STR_ID_NOT_FOUND , messageString->GetString( ) ,
strlen( STR_ID_NOT_FOUND )) != 0 )
{
DoAssemble( messageString ) ;
return messageString ;
} /* end if */
delete messageString ;
messageString = NULL ;
// Assemble with error message string id
// Assemble with error message string
messageString = new STR_String( MSG_ErrorIdNotFound ) ;
if ( vtItems[ INX_LAST_ITEM ] != NULL )
{
delete vtItems[ INX_LAST_ITEM ] ;
} /* if */
vtItems[ INX_LAST_ITEM ] = new MSG_ItemInteger( idMessage & STR_ID ) ;
DoAssemble( messageString ) ;
// Append items to nonexisting message
char ASCIINum[ BCD_DIM_MAX_ASCII ] ;
STR_String Separator( MSG_Separator ) ;
STR_String SeparatorEnd( MSG_SeparatorEnd ) ;
for( int i = 0 ; i < MSG_DIM_ITEMS - 1 ; i ++ )
{
if ( vtItems[ i ] != NULL )
{
messageString->Append( Separator ) ;
sprintf( ASCIINum , "%d" , i ) ;
messageString->Append( ASCIINum ) ;
messageString->Append( SeparatorEnd ) ;
STR_String * pItemStr = vtItems[ i ]->ToString() ;
messageString->Append( pItemStr ) ;
delete pItemStr ;
} /* if */
} /* for */
return messageString ;
} // End of function: MSG !Assemble the message string
示例12: GetParent
void SCA_KeyboardSensor::AddToTargetProp(int keyIndex, int unicode)
{
if (IsPrintable(keyIndex)) {
CValue* tprop = GetParent()->GetProperty(m_targetprop);
if (IsDelete(keyIndex)) {
/* Make a new property. Deletes can be ignored. */
if (tprop) {
/* overwrite the old property */
/* strip one char, if possible */
STR_String newprop = tprop->GetText();
int oldlength = newprop.Length();
if (oldlength >= 1 ) {
int newlength=oldlength;
BLI_str_cursor_step_prev_utf8(newprop, newprop.Length(), &newlength);
newprop.SetLength(newlength);
CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
GetParent()->SetProperty(m_targetprop, newstringprop);
newstringprop->Release();
}
}
}
else {
char utf8_buf[7];
size_t utf8_len;
utf8_len = BLI_str_utf8_from_unicode(unicode, utf8_buf);
utf8_buf[utf8_len] = '\0';
STR_String newprop = tprop ? (tprop->GetText() + utf8_buf) : utf8_buf;
CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
GetParent()->SetProperty(m_targetprop, newstringprop);
newstringprop->Release();
}
}
}
示例13: CreateShaderProgram
void RAS_2DFilterManager::EnableFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text)
{
if(!isshadersupported)
return;
if(pass<0 || pass>=MAX_RENDER_PASS)
return;
need_tex_update = true;
if(mode == RAS_2DFILTER_DISABLED)
{
m_enabled[pass] = 0;
return;
}
if(mode == RAS_2DFILTER_ENABLED)
{
m_enabled[pass] = 1;
return;
}
if(mode == RAS_2DFILTER_NOFILTER)
{
if(m_filters[pass])
glDeleteObjectARB(m_filters[pass]);
m_enabled[pass] = 0;
m_filters[pass] = 0;
m_gameObjects[pass] = NULL;
m_properties[pass].clear();
texflag[pass] = 0;
return;
}
if(mode == RAS_2DFILTER_CUSTOMFILTER)
{
if(m_filters[pass])
glDeleteObjectARB(m_filters[pass]);
m_filters[pass] = CreateShaderProgram(text.Ptr());
m_gameObjects[pass] = gameObj;
AnalyseShader(pass, propNames);
m_enabled[pass] = 1;
return;
}
// We've checked all other cases, which means we must be dealing with a builtin filter
if(m_filters[pass])
glDeleteObjectARB(m_filters[pass]);
m_filters[pass] = CreateShaderProgram(mode);
m_gameObjects[pass] = NULL;
AnalyseShader(pass, propNames);
m_enabled[pass] = 1;
}
示例14: RenderText
void GPC_RenderTools::RenderText(
int mode,
RAS_IPolyMaterial* polymat,
float v1[3], float v2[3], float v3[3], float v4[3], int glattrib)
{
STR_String mytext = ((CValue*)m_clientobject)->GetPropertyText("Text");
const unsigned int flag = polymat->GetFlag();
struct MTFace* tface = 0;
unsigned int *col = 0;
if(flag & RAS_BLENDERMAT) {
KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(polymat);
tface = bl_mat->GetMTFace();
col = bl_mat->GetMCol();
} else {
KX_PolygonMaterial* blenderpoly = static_cast<KX_PolygonMaterial*>(polymat);
tface = blenderpoly->GetMTFace();
col = blenderpoly->GetMCol();
}
GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib);
}
示例15: while
std::vector<STR_String> STR_String::Explode(char c) const
{
STR_String lcv = *this;
std::vector<STR_String> uc;
while (lcv.Length()) {
int pos = lcv.Find(c);
if (pos < 0) {
uc.push_back(lcv);
lcv.Clear();
}
else {
uc.push_back(lcv.Left(pos));
lcv = lcv.Mid(pos + 1);
}
}
//uc. -= STR_String("");
return uc;
}