• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ mgString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中mgString的典型用法代码示例。如果您正苦于以下问题:C++ mgString类的具体用法?C++ mgString怎么用?C++ mgString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了mgString类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: mgOSFindFile

//--------------------------------------------------------------
// find a file in parent directories
BOOL mgOSFindFile(
  mgString& location,
  const char* fileName)
{
  WCHAR* oldCWD = _wgetcwd(NULL, 0);
  if (oldCWD == NULL)
    return false;
  mgString cwd(oldCWD);

  while (true)
  {
    if (cwd.endsWith("\\"))
      location.format("%s%s", (const char*) cwd, fileName);
    else location.format("%s\\%s", (const char*) cwd, fileName);

    WCHAR* wideName;
    int wideLen;
    location.toWCHAR(wideName, wideLen);
    struct _stat filestat;
    BOOL found = 0 == _wstat(wideName, &filestat);
    delete wideName; wideName = NULL;

    if (found)
      return true;
    else
    {
      // remove last directory from cwd
      int slash = cwd.reverseFind(cwd.length(), '\\');
      if (slash != -1)
        cwd.deleteAt(slash, cwd.length()-slash);
      else return false;   // no more directories. file not found.
    }
  }
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:36,代码来源:mgWinFileUtil.cpp


示例2: debugSetVariable

//-----------------------------------------------------------------------------
// set a variable
void SeaOfMemes::debugSetVariable(
  const char* varName,
  const char* value,
  mgString& reply) 
{
  if (m_world == NULL)
  {
    reply.format("cannot set %s", varName);
    return;
  }

  double len;
  if (1 != sscanf(value, "%lf", &len))
  {
    reply.format("invalid value %s", value);
    return;
  }
  // keep rotation times in range
  len = max(1, len);

  reply = "ok";

  if (_stricmp(varName, "planetDayLen") == 0)
    m_world->m_planetDayLen = len;
  else if (_stricmp(varName, "moonDayLen") == 0)
    m_world->m_moonDayLen = len;
  else if (_stricmp(varName, "ringDayLen") == 0)
    m_world->m_ringDayLen = len;
  else if (_stricmp(varName, "moonMonthLen") == 0)
    m_world->m_moonMonthLen = len;
  else if (_stricmp(varName, "beltMonthLen") == 0)
    m_world->m_beltMonthLen = len;
  
  else reply.format("cannot set %s" ,varName);
}
开发者ID:duaneking,项目名称:SeaOfMemes,代码行数:37,代码来源:SeaOfMemes.cpp


示例3: mgOSFindFile

//--------------------------------------------------------------
// find a file in parent directories
BOOL mgOSFindFile(
  mgString& location,
  const char* fileName)
{
  char* oldCWD = getcwd(NULL, 0);
  if (oldCWD == NULL)
    return false;

  mgString cwd(oldCWD);
  while (true)
  {
    if (cwd.endsWith("/"))
      location.format("%s%s", (const char*) cwd, fileName);
    else location.format("%s/%s", (const char*) cwd, fileName);

    struct stat filestat;
    if (0 == stat(location, &filestat))
      return true;
    else
    {
      // remove last directory from cwd
      int slash = cwd.reverseFind(cwd.length(), '/');
      if (slash != -1)
        cwd.deleteAt(slash, cwd.length()-slash);
      else return false;  // no more directories. file not found.
    }
  }
}
开发者ID:duaneking,项目名称:SeaOfMemes,代码行数:30,代码来源:mgLinuxFileUtil.cpp


示例4: glGetShaderiv

//--------------------------------------------------------------------------
// return shader log error messages as a string
void mgLinuxGL33Support::getShaderLog(
  GLuint shader,
  mgString& log)
{
  GLint logLen, retLen;
  glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLen);
  char* logText = new char[logLen];
  glGetShaderInfoLog(shader, logLen, &retLen, logText);
  log.empty();
  log.write((const char*) logText, retLen);
  delete logText;
}
开发者ID:duaneking,项目名称:SeaOfMemes,代码行数:14,代码来源:mgLinuxGL33Support.cpp


示例5: GL21getShaderLog

//--------------------------------------------------------------------------
// get shader log error messages as string
void GL21getShaderLog(
  GLuint shader,
  mgString& logStr)
{
  GLint logLen, retLen;
  glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLen);
  char* logText = new char[logLen];
  glGetShaderInfoLog(shader, logLen, &retLen, logText);
  logStr.empty();
  logStr.write(logText, retLen);
  delete logText;
}
开发者ID:duaneking,项目名称:SeaOfMemes,代码行数:14,代码来源:mgGL21Misc.cpp


示例6: glGetString

//--------------------------------------------------------------
// check version of OpenGL available
BOOL mgLinuxGL33Support::checkVersion(
  int reqGLVersion,
  int reqShaderVersion,
  mgString& errorMsg)
{
  const char* glVersionStr = (const char*) glGetString(GL_VERSION);
  if (glVersionStr == NULL)
  {
    errorMsg = "cannot read OpenGL version";
    return false;
  }

  int major, minor, glVersion;
  if (2 != sscanf(glVersionStr, "%d.%d", &major, &minor))
  {
    errorMsg.format("cannot parse OpenGL version %s", (const char*) glVersionStr);
    return false;
  }
  // trim trailing zeros.  3.3 and 3.30 are the same
  while (minor%10 == 0)
    minor /= 10;

  glVersion = major*100 + minor;

  const char* shaderVersionStr = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION);
  if (shaderVersionStr == NULL)
  {
    errorMsg = "cannot read OpenGL Shader Language version";
    return false;
  }

  int shaderVersion;
  if (2 != sscanf(shaderVersionStr, "%d.%d", &major, &minor))
  {
    errorMsg.format("cannot parse OpenGL version %s", (const char*) shaderVersionStr);
    return false;
  }
  // trim trailing zeros.  3.3 and 3.30 are the same
  while (minor%10 == 0)
    minor /= 10;

  shaderVersion = major*100 + minor;

  if (glVersion < reqGLVersion || shaderVersion < reqShaderVersion)
  {
    errorMsg.format("App requested OpenGl %d.%d, shader %d.%d\nSystem has OpenGL %d.%d, shader %d.%d", 
      reqGLVersion/100, reqGLVersion%100, reqShaderVersion/100, reqShaderVersion%100,
      glVersion/100, glVersion%100, shaderVersion/100, shaderVersion%100);
    return false;
  }

  return true;
}
开发者ID:duaneking,项目名称:SeaOfMemes,代码行数:55,代码来源:mgLinuxGL33Support.cpp


示例7: debugGetVariable

//-----------------------------------------------------------------------------
// return value of variable
void SeaOfMemes::debugGetVariable(
  const char* varName,
  mgString& value) 
{
  mgPoint3 eyePt;
  if (m_world == NULL)
  {
    value = "unknown";
    return;
  }

  m_world->getEyePt(eyePt);

  if (_stricmp(varName, "eyePt.x") == 0)
    value.format("%g", eyePt.x);
  else if (_stricmp(varName, "eyePt.y") == 0)
    value.format("%g", eyePt.y);
  else if (_stricmp(varName, "eyePt.z") == 0)
    value.format("%g", eyePt.z);

  else if (_stricmp(varName, "planetDayLen") == 0)
    value.format("%g", m_world->m_planetDayLen);
  else if (_stricmp(varName, "moonDayLen") == 0)
    value.format("%g", m_world->m_moonDayLen);
  else if (_stricmp(varName, "ringDayLen") == 0)
    value.format("%g", m_world->m_ringDayLen);
  else if (_stricmp(varName, "moonMonthLen") == 0)
    value.format("%g", m_world->m_moonMonthLen);
  else if (_stricmp(varName, "beltMonthLen") == 0)
    value.format("%g", m_world->m_beltMonthLen);

  else value = "unknown variable";
}
开发者ID:duaneking,项目名称:SeaOfMemes,代码行数:35,代码来源:SeaOfMemes.cpp


示例8: commaFormat

//--------------------------------------------------------------
// comma format speed
void SpeedUI::commaFormat(
  mgString& line,
  const char* suffix,
  int value)
{
  line.format("%d %s", value, (const char*) suffix);

  // add the commas
  int posn = line.find(0, ' ')-3;
  while (posn > 0)
  {
    line.insertAt(posn, ",", 1);
    posn -= 3;
  }
}
开发者ID:bond4u,项目名称:SeaOfMemes,代码行数:17,代码来源:SpeedUI.cpp


示例9: error

//--------------------------------------------------------------
// substitute vars into message and return
void mgErrorTable::unknownMsg(
  mgString& text,               // returned message text
  const char* msgId,
  const char* varNames,
  const char* varValues)
{
  // no error message, so format args
  text.format("Unknown error(%s)", (const char*) msgId);
  int namePosn = 0;
  int valuePosn = 0;

  mgString argName;
  mgString argValue;
  while (true)
  {
    namePosn = parseVar(argName, varNames, namePosn);
    valuePosn = parseVar(argValue, varValues, valuePosn);
    if (namePosn == -1 || valuePosn == -1)
      break;

    text += ", ";
    text += argName;
    text += "=\"";
    text += argValue;
    text += "\"";
  }
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:29,代码来源:mgErrorTable.cpp


示例10: processInput

//--------------------------------------------------------------
// process input line
void mgDebugPane::processInput(
  const mgString& input)
{
  mgString verb;
  int posn = input.getToken(0, " *(=", verb);

  if (verb.equalsIgnoreCase("help"))
  {
    mgString helpText;
    m_debugApp->debugHelp(helpText);
    m_console->addLine(OUTPUT_COLOR, NULL, helpText);
  }
  else if (verb.equalsIgnoreCase("list"))
  {
    listVariables();
    listFunctions();
  }
  else
  {
    if (!parseGetVariable(input))
    {
      if (!parseSetVariable(input))
      {
        if (!parseCallFunction(input))
          m_console->addLine(ERROR_COLOR, NULL, "Unknown command.");
      }
    }
  }
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:31,代码来源:mgDebugPane.cpp


示例11: mgOSFixFileName

//--------------------------------------------------------------
// set slashes appropriately for OS
void mgOSFixFileName(
  mgString& name)
{
  name.trim();

  // convert any backslashes to forward slashes
  mgString bs("/");
  char letter[MG_MAX_LETTER];
  int posn = 0;
  while (posn < name.length())
  {
    int next = name.nextLetter(posn, letter);
    if (strcmp(letter, "\\") == 0)
      next = name.setLetter(posn, bs);
    posn = next;
  }
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:19,代码来源:mgScriptFileUtil.cpp


示例12: getCursorX

//--------------------------------------------------------------
// get cursor X coordinate
int mgSimpleField::getCursorX(
  const mgString& displayStr)
{
  int cursorX = 0;
  int posn = m_cursorPosn - m_scrollPosn;
  
  // if cursor position within displayed text
  if (posn <= displayStr.length())
  {
    // measure string from scroll position up to cursor
    cursorX = m_font->stringWidth(displayStr, posn);
  }
  else
  {
    // measure string from scroll position, plus blanks to cursor position
    cursorX = m_font->stringWidth(displayStr, displayStr.length());
    cursorX += m_font->stringWidth(" ", 1) * (posn - displayStr.length());
  }
  
  return cursorX;
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:23,代码来源:mgSimpleField.cpp


示例13: mgOSResolveRelativeName

//--------------------------------------------------------------
// resolve possibly relative file name.  
void mgOSResolveRelativeName(
  const char* sourceFile,
  const char* relName,
  mgString& absName)
{
  mgString name(relName);
  mgOSFixFileName(name);

  // if relative name starts with /, we're done
  if (name.startsWith("/"))
  {
    absName = name;
    return;
  }

  // assume it's really relative.  strip last directory in source file
  absName = sourceFile;
  int lastSlash = absName.reverseFind(absName.length(), "/");
  if (lastSlash != -1)
    absName.deleteAt(lastSlash+1, absName.length()-(lastSlash+1));
  else absName.empty();  // source file has no dir
  
  absName += name;
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:26,代码来源:mgScriptFileUtil.cpp


示例14: parseVar

//--------------------------------------------------------------
// parse a name or value off the strings
int mgErrorTable::parseVar(
  mgString& value,
  const char* argString,
  int posn)
{
  value.empty();
  while (true)
  {
    char c = argString[posn++];
    if (c == '\0')
      return -1;
    if (c == MG_ERROR_DELIM)
      return posn;

    value += c;
  }
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:19,代码来源:mgErrorTable.cpp


示例15: debugStats

//--------------------------------------------------------------
// write stats to debug
void ChunkWorld::debugStats(
  mgString& status)
{
  m_chunkLock->lock();

  int unloadedCount = 0;
  int inmemoryCount = 0;
  int indisplayCount = 0;
  int needsUpdateCount = 0;

  ChunkListNode* lruItem = m_LRUList.m_first;
  while (lruItem != NULL)
  {
    ChunkObj* oldest = lruItem->m_chunk;
    switch (oldest->m_status)
    {
      case CHUNK_UNLOADED:
        unloadedCount++;
        break;
      case CHUNK_INMEMORY:
        inmemoryCount++;
        break;
      case CHUNK_INDISPLAY:
        indisplayCount++;
        break;
      case CHUNK_NEEDSUPDATE:
        needsUpdateCount++;
        break;
    }

    lruItem = lruItem->m_next;
  }

  status.format("system memory = %gM (%d chunks), display memory = %gM (%d chunks), update = %d, LRU = %d chunks (%d unloaded)",
        m_systemMemUsed/(1024*1024.0), inmemoryCount,
        m_displayMemUsed/(1024*1024.0), indisplayCount,
        needsUpdateCount,
        m_LRUList.length(), unloadedCount); 

  m_chunkLock->unlock();
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:43,代码来源:ChunkWorld.cpp


示例16: mgOSResolveRelativeName

//--------------------------------------------------------------
// resolve possibly relative file name.  
void mgOSResolveRelativeName(
  const char* sourceName,
  const char* relName,
  mgString& absName)
{
  mgString name(relName);
  mgOSFixFileName(name);

  // if relative name starts with backslash, we're done
  if (name.startsWith("\\"))
  {
    absName = name;
    return;
  }

  // if relative name starts with X: (drive letter), we're done
  char letter[MG_MAX_LETTER];
  int posn = name.nextLetter(0, letter);
  if (posn < name.length())
  {
    posn = name.nextLetter(posn, letter);
    if (strcmp(letter, ":") == 0)
    {
      absName = name;
      return;
    }
  }

  // assume it's really relative.  strip last directory in source file
  mgString sourceFile(sourceName);
  int lastSlash = sourceFile.reverseFind(sourceFile.length(), '\\');
  if (lastSlash != -1)
    sourceFile.substring(absName, 0, lastSlash+1);
  else absName.empty();  // source file has no dir

  absName += name;
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:39,代码来源:mgWinFileUtil.cpp


示例17: appDebugStats

//-----------------------------------------------------------------------------
// report status for debug log
void Landscape::appDebugStats(
  mgString& status)
{
  status.format("max count = %d", m_maxCount);
}
开发者ID:bond4u,项目名称:SeaOfMemes,代码行数:7,代码来源:Landscape.cpp


示例18: getFont

//-----------------------------------------------------------------
// get font string
void mgTextBuffer::getFont(
  mgString& fontSpec)
{
  fontSpec.format("%s-%d%s%s", (const char*) m_fontFace, m_fontSize, 
    m_fontBold == mgTrue? "-b" : "", m_fontItalic == mgTrue ? "-i" : "");
}
开发者ID:duaneking,项目名称:SeaOfMemes,代码行数:8,代码来源:mgTextBuffer.cpp



注:本文中的mgString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ mglParse类代码示例发布时间:2022-05-31
下一篇:
C++ methodOop类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap