TEST(stdio, stream_ops_wide) { std::wstringstream sstream; sstream << ST_LITERAL("xxxxx") << L" " << ST_LITERAL("yyyyy"); sstream.seekg(0); ST::string x, y; sstream >> x; sstream >> y; EXPECT_EQ(ST_LITERAL("xxxxx"), x); EXPECT_EQ(ST_LITERAL("yyyyy"), y); }
void plAgeDescInterface::INewPage() { ST::string name = ST_LITERAL("New Page Name"); // Get the name of the new age from the user int ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_AGE_NAME), GetCOREInterface()->GetMAXHWnd(), NewAgeDlgProc, (LPARAM)&name); if (ret != 1) return; HWND hPages = GetDlgItem(fhDlg, IDC_PAGE_LIST); // Make sure this page doesn't already exist int count = ListBox_GetCount(hPages); for (int i = 0; i < count; i++) { char pageName[256]; ListBox_GetText(hPages, i, pageName); if (!name.compare_i(pageName)) return; } // Add the new page and select it int idx = ListBox_AddString(hPages, name.c_str()); // Choose a new sequence suffix for it plAgePage *newPage = new plAgePage( name, IGetFreePageSeqSuffix( hPages ), 0 ); ListBox_SetItemData( hPages, idx, (LPARAM)newPage ); fDirty = true; }
ST::string DS::SockIpAddress(const DS::SocketHandle sock) { char addrbuf[256]; SocketHandle_Private* sockp = reinterpret_cast<SocketHandle_Private*>(sock); if (!inet_ntop(sockp->m_addr.sa_family, get_in_addr(sockp), addrbuf, 256)) { fprintf(stderr, "Failed to get socket address: %s\n", strerror(errno)); return ST_LITERAL("???"); } return ST::format("{}/{}", addrbuf, get_in_port(sockp)); }
void plAgeDescInterface::INewAge() { VARIANT assetId; VariantInit(&assetId); #ifdef MAXASS_AVAILABLE bool makeAsset = true; if( hsMessageBox( "Do you wish to store your new age in AssetMan?", "Make source-controlled?", hsMessageBoxYesNo ) == hsMBoxNo ) makeAsset = false; #endif plFileName newAssetFilename; #ifdef MAXASS_AVAILABLE if (!fAssetManIface) makeAsset = false; #endif newAssetFilename = IGetLocalAgePath(); if (!newAssetFilename.IsValid()) return; ST::string name = ST_LITERAL("New Age Name"); // Get the name of the new age from the user int ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_AGE_NAME), GetCOREInterface()->GetMAXHWnd(), NewAgeDlgProc, (LPARAM)&name); if (ret != 1) return; newAssetFilename = plFileName::Join(newAssetFilename, name + ".age"); #ifdef MAXASS_AVAILABLE if( !makeAsset ) fForceSeqNumLocal = true; ISetControlDefaults(); ISaveCurAge(newAssetFilename, true); // Check sequence # while we're at it fForceSeqNumLocal = false; if( makeAsset ) (*fAssetManIface)->AddNewAsset(newAssetFilename.AsString().c_str()); #endif // Refresh the tree now IFillAgeTree(); }
plLayer* hsGMaterial::MakeBaseLayer() { plLayer* newLay = new plLayer; newLay->InitToDefault(); IClearLayers(); hsAssert(GetKey(), "All materials need a key (or temp key)"); ST::string buff; if( !GetKeyName().is_empty() ) buff = ST::format("{}_Layer", GetKeyName()); else buff = ST_LITERAL("Layer"); hsgResMgr::ResMgr()->NewKey( buff, newLay, GetKey() != nil ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); // Add layer so we have it now. AddLayerViaNotify(newLay); return newLay; }
// // Parse a variable descriptor. // read type, name, count [default] // return true to skip the next token read // bool plSDLParser::IParseVarDesc(const plFileName& fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc, plVarDescriptor*& curVar) const { hsAssert(curDesc, ST::format("Syntax problem with .sdl file, fileName={}", fileName).c_str()); if ( !curDesc ) return false; bool skipNext=false; ST::string dbgStr; static char seps[] = "( ,)[]"; // read type, name, cnt, [default] // // TYPE // create new state var, make current // if (*token == '$') { // nested sdls char* sdlName = token+1; plStateDescriptor* stateDesc = plSDLMgr::GetInstance()->FindDescriptor(sdlName, plSDL::kLatestVersion); hsAssert(stateDesc, ST::format("can't find nested state desc reference {}, fileName={}", sdlName, fileName).c_str()); curVar = new plSDVarDescriptor(stateDesc); } else curVar = new plSimpleVarDescriptor; curDesc->AddVar(curVar); bool ok=curVar->SetType(token); hsAssert(ok, ST::format("Variable 'type' syntax problem with .sdl file, type={}, fileName={}", token, fileName).c_str()); dbgStr = ST::format("\tVAR Type={} ", token); // // NAME (foo[1]) // if (stream->GetToken(token, kTokenLen)) { hsAssert(strstr(token, "[") != nullptr && strstr(token, "]") != nullptr, ST::format("invalid var syntax, missing [x], fileName={}", fileName).c_str()); char* ptr = strtok( token, seps ); // skip [ hsAssert(curVar, ST::format("Missing current var. Syntax problem with .sdl file, fileName={}", fileName).c_str()); curVar->SetName(token); // // COUNT // char* cntTok=strtok(nil, seps); // kill ] int cnt = cntTok ? atoi(cntTok) : 0; curVar->SetCount(cnt); if (cnt==0) curVar->SetVariableLength(true); dbgStr += ST::format("Name={}[{}]", curVar->GetName(), cnt); } // // optional tokens: DEFAULT, INTERNAL // while (stream->GetToken(token, kTokenLen)) { if (!strcmp(token, "DEFAULT")) { hsAssert(curVar, ST::format("Syntax problem with .sdl file, fileName={}", fileName).c_str()); // read state var type ST::string defaultStr; plSimpleVarDescriptor* sVar=(plSimpleVarDescriptor*)curVar; if (sVar) { int i; for(i=0;i<sVar->GetAtomicCount();i++) { if (stream->GetToken(token, kTokenLen)) { defaultStr += token; if (i!=sVar->GetAtomicCount()-1) defaultStr += ","; } } } if (!defaultStr.is_empty()) { curVar->SetDefault(defaultStr); dbgStr += " DEFAULT=" + defaultStr; } } else if (!strcmp(token, "DISPLAYOPTION")) { hsAssert(curVar, ST::format("Syntax problem with .sdl file, fileName={}", fileName).c_str()); dbgStr += ST_LITERAL(" ") + token; bool read=stream->GetToken(token, kTokenLen); if (read) { ST::string oldOptions=curVar->GetDisplayOptions(); if (!oldOptions.is_empty()) oldOptions += ","; oldOptions += token; curVar->SetDisplayOptions(oldOptions); dbgStr += ST_LITERAL("=") + token; if (!stricmp(token, "hidden")) curVar->SetInternal(true); } else { hsAssert(false, ST::format("missing displayOption string, fileName={}", fileName).c_str()); } } else if (!strcmp(token, "DEFAULTOPTION")) { hsAssert(curVar, ST::format("Syntax problem with .sdl file, fileName={}", fileName).c_str()); dbgStr += ST_LITERAL(" ") + token; bool read=stream->GetToken(token, kTokenLen); if (read) { dbgStr += ST_LITERAL("=") + token; if (!stricmp(token, "vault")) curVar->SetAlwaysNew(true); } else { hsAssert(false, ST::format("missing defaultOption string, fileName={}", fileName).c_str()); } } #if 1 // delete me in May 2003 else if (!strcmp(token, "INTERNAL")) { hsAssert(curVar, ST::format("Syntax problem with .sdl file, fileName={}", fileName).c_str()); curVar->SetInternal(true); dbgStr += ST_LITERAL(" ") + token; } else if (!strcmp(token, "PHASED")) { hsAssert(curVar, ST::format("Syntax problem with .sdl file, fileName={}", fileName).c_str()); curVar->SetAlwaysNew(true); dbgStr += ST_LITERAL(" ") + token; } #endif else { skipNext=true; break; } } DebugMsg(dbgStr); return skipNext; }
bool plAnimComponentBase::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) { // If this is the first time in the preconvert, reset the map if (fNeedReset) { fNeedReset = false; } // If this node is animated, create it's modifier and key now so we can give // it out to anyone that needs it // if (node->IsTMAnimated() || node->IsAnimatedLight()) // { const char *name = node->GetName(); plAGMasterMod *mod = node->GetAGMasterMod(); if (mod == nil) { if (!node->HasAGMod()) // Need to add this before the MasterMod, if it doesn't have one already. { node->AddModifier(new plAGModifier(ST::string::from_utf8(node->GetName())), IGetUniqueName(node)); } mod = new plAGMasterMod(); plKey modKey = node->AddModifier(mod, IGetUniqueName(node)); } fMods[node] = mod; // } // Small change here. We're setting up the timing specs on the // plAGAnim object during preconvert, so that the info is available // when actually converting the anim (and for other components // that need it, but may or may not actually convert before us.) // Note: if the component uses the "(Entire Animation)" segment for // the main start/end, the start/end times won't be valid until // we've added all keys during convert. Some cleanup might // be necessary in this case. ST::string animName = ST::string::from_utf8(fCompPB->GetStr(kAnimName)); if (animName.is_empty()) animName = ST_LITERAL(ENTIRE_ANIMATION_NAME); if (fCompPB->GetInt(ParamID(kAnimUseGlobal))) { plAgeGlobalAnim *ageAnim = new plAgeGlobalAnim(animName, 0, 0); ageAnim->SetGlobalVarName((char*)fCompPB->GetStr(ParamID(kAnimGlobalName))); fAnims[node] = ageAnim; } else { plATCAnim *ATCAnim = new plATCAnim(animName, 0, 0); plNotetrackAnim noteAnim(node, pErrMsg); plAnimInfo info = noteAnim.GetAnimInfo(animName); ATCAnim->SetAutoStart(fCompPB->GetInt(kAnimAutoStart)); float start = info.GetAnimStart(); float end = info.GetAnimEnd(); float initial = info.GetAnimInitial(); if (start != -1) ATCAnim->SetStart(start); if (end != -1) ATCAnim->SetEnd(end); if (initial != -1) ATCAnim->SetInitial(initial); if (fCompPB->GetInt(kAnimLoop)) { ATCAnim->SetLoop(true); ST::string loopName = ST::string::from_utf8(fCompPB->GetStr(kAnimLoopName)); float loopStart = info.GetLoopStart(loopName); float loopEnd = info.GetLoopEnd(loopName); ATCAnim->SetLoopStart(loopStart == -1 ? ATCAnim->GetStart() : loopStart); ATCAnim->SetLoopEnd(loopEnd == -1 ? ATCAnim->GetEnd() : loopEnd); } ST::string loop; while (!(loop = info.GetNextLoopName()).is_empty()) ATCAnim->AddLoop(loop, info.GetLoopStart(loop), info.GetLoopEnd(loop)); ST::string marker; while (!(marker = info.GetNextMarkerName()).is_empty()) ATCAnim->AddMarker(marker, info.GetMarkerTime(marker)); float stopPoint = -1; while ((stopPoint = info.GetNextStopPoint()) != -1) ATCAnim->AddStopPoint(stopPoint); ATCAnim->SetEaseInType(fCompPB->GetInt(kAnimEaseInType)); ATCAnim->SetEaseOutType(fCompPB->GetInt(kAnimEaseOutType)); ATCAnim->SetEaseInLength(fCompPB->GetFloat(kAnimEaseInLength)); ATCAnim->SetEaseInMin(fCompPB->GetFloat(kAnimEaseInMin)); ATCAnim->SetEaseInMax(fCompPB->GetFloat(kAnimEaseInMax)); ATCAnim->SetEaseOutLength(fCompPB->GetFloat(kAnimEaseOutLength)); ATCAnim->SetEaseOutMin(fCompPB->GetFloat(kAnimEaseOutMin)); ATCAnim->SetEaseOutMax(fCompPB->GetFloat(kAnimEaseOutMax)); fAnims[node] = ATCAnim; } return true; }