ZString GetString(int indent)
    {
        ZString str = "Lights([\n";

        LightDataList::Iterator iter(m_list);

        while (!iter.End()) {
            LightData& data = iter.Value();

            str +=
                Indent(indent + 1)
                + "( " + ::GetString(indent, data.m_color)
                + ", " + ::GetString(indent, data.m_vec)
                + ", " + ZString(data.m_period)
                + ", " + ZString(data.m_phase)
                + ", " + ZString(data.m_rampUp)
                + ", " + ZString(data.m_hold)
                + ", " + ZString(data.m_rampDown)
                + ")";

            iter.Next();

            if (iter.End()) {
                str += "\n";
            } else {
                str += ",\n";
            }
        }

        return str + Indent(indent) + "])";
    }
Example #2
0
ZString ZString::replace(std::string before, std::string after, bool modify){
    std::string tmpdata = data;
    std::string tmp = "";
    for(unsigned i = 0; i < tmpdata.length(); ++i){
        if(tmpdata[i] == before[0]){
            bool match = true;
            int last = 0;
            for(unsigned j = 0; j < before.length(); ++j){
                if(tmpdata[i+j] != before[j]){
                    match = false;
                    break;
                }
                last = i + j;
            }
            if(match){
                std::string pre = tmpdata.substr(0, i);
                std::string suff = tmpdata.substr(last+1);
                tmp = tmp.append(pre).append(after);
                tmpdata = suff;
                i = -1;
            }
        }
    }
    tmp = tmp.append(tmpdata);

    if(modify){
        data = tmp;
        return ZString(data);
    } else {
        return ZString(tmp);
    }
}
 void ZTraceImpl(const char* pcc)
 {
     if (g_bEnableTrace) {
         ZDebugOutput(ZString((float)g_line, 4, 0) + g_strSpaces + ZString(pcc) + "\n");
     }
     g_line++;
 }
Example #4
0
    ZString GetString(int indent)
    {
        // KeyFramedTranslate([ time, x, y, z ], frame)

        ZString str = "KeyFramedTranslate(\n" + Indent(indent + 1) + "[\n";

        int count = m_keys.GetCount();
        for (int index = 0; index < count; index++) {
            str +=
                  Indent(indent + 2)
                + ZString(m_keys[index].m_frame) + ", "
                + ZString(m_keys[index].m_vec.X()) + ", "
                + ZString(m_keys[index].m_vec.Y()) + ", "
                + ZString(m_keys[index].m_vec.Z());

            if (index < count - 1) {
                str += ",\n";
            } else {
                str += "\n";
            }
        }

        return
              str
            + Indent(indent + 1) + "],\n"
            + Indent(indent + 1) + GetFrame()->GetChildString(indent + 1) + "\n"
            + Indent(indent) + ")";
    }
Example #5
0
ZString GetString(int indent, const Point& point)
{
    return
          "Point("
        + ZString(point.X()) + ", "
        + ZString(point.Y()) + ")";
}
 void SetStrSpaces()
 {
     g_strSpaces = 
           " "
         + ZString((float)g_indent, 2, 0) 
         + ZString(' ', g_indent * 2 + 1);
 }
Example #7
0
ZString GetString(int indent, const Color& color)
{
    return
          "Color("
        + ZString(color.GetRed()  ) + ", "
        + ZString(color.GetGreen()) + ", "
        + ZString(color.GetBlue() ) + ")";
}
Example #8
0
ZString GetString(int indent, const Vector& vec)
{
    return
          "Vector("
        + ZString(vec.X()) + ", "
        + ZString(vec.Y()) + ", "
        + ZString(vec.Z()) + ")";
}
Example #9
0
ZString GetString(int indent, const Rect& Rect)
{
    return
          "Rect("
        + ZString(Rect.XMin()) + ", "
        + ZString(Rect.YMin()) + ", "
        + ZString(Rect.XMax()) + ", "
        + ZString(Rect.YMax()) + ")";
}
Example #10
0
ZString ZString::toJSON(AsArZ arr, bool modify){
    ZString tmp;
    tmp << "{\"" << ZString(arr.getIndex(0)).replace("\"", "\\\"").str() << "\":\"" << arr[0].replace("\"", "\\\"") << "\"";
    for(unsigned i = 1; i < arr.size(); ++i)
        tmp << ",\"" << ZString(arr.getIndex(i)).replace("\"", "\\\"").str() << "\":\"" << arr[i].replace("\"", "\\\"") << "\"";
    tmp << "}";
    if(modify)
        data = tmp.str();
    return tmp;
}
Example #11
0
ZString ZString::substr(int pos, int npos, bool modify){
    std::string tmp = data;
    tmp.substr(pos, npos);

    if(modify){
        data = tmp;
        return ZString(data);
    } else {
        return ZString(tmp);
    }
}
bool CLobbyApp::OnAssert(const char* psz, const char* pszFile, int line, const char* pszModule)
{
  m_plas->LogEvent(EVENTLOG_ERROR_TYPE, LE_Assert, ZString("'")
            + psz
            + "' ("
            + pszFile
            + ":"
            + ZString(line)
            + ")\n"
  );
  return true;
}
Example #13
0
ZString ZString::invert(bool modify){
    std::string buff;
    for(unsigned i = data.length(); i > 0; --i){
        buff += data[i];
    }

    if(modify){
        data = buff;
        return ZString(data);
    } else {
        return ZString(buff);
    }
}
Example #14
0
ZString ZFile::readFile(ZString filename){
    std::ifstream infile(filename.cc(), std::ios::in | std::ios::binary);
    if(infile){
        std::string buffer;
        infile.seekg(0, std::ios::end);
        buffer.resize(infile.tellg());
        infile.seekg(0, std::ios::beg);
        infile.read(&buffer[0], buffer.size());
        infile.close();
        return(ZString(buffer));
    }
    return ZString();
}
Example #15
0
ZString WebSession::generateId(){
    string tmpid = randomId(20);
    QDir dir(SESSION_PATH);
    QList<QFileInfo> flist = dir.entryInfoList();
    for(int i = 0; i < flist.size(); ++i){
        if(flist[i].isFile()){
            if(flist[i].fileName() == ZString(tmpid).QS()){
                tmpid = randomId(20);
                i = -1;
            }
        }
    }
    return ZString(tmpid);
}
Example #16
0
ZString ZString::toLower(bool modify){
    std::string tmp = data;
    for(unsigned i = 0; i < data.size(); ++i){
        // Custom tolower()
        //if((int)tmp[i] >= 65 && (int)tmp[i] <= 90)
        //    tmp[i] = (char)((int)tmp[i] + 32);
        tmp[i] = tolower(tmp[i]);
    }
    if(modify){
        data = tmp;
        return ZString(data);
    } else {
        return ZString(tmp);
    }
}
bool Win32App::OnAssert(const char* psz, const char* pszFile, int line, const char* pszModule)
{
    ZDebugOutput(
          ZString("assertion failed: '")
        + psz
        + "' ("
        + pszFile
        + ":"
        + ZString(line)
        + ")\n"
    );

    //return _CrtDbgReport(_CRT_ASSERT, pszFile, line, pszModule, psz) == 1;
    return true;
}
Example #18
0
void ZProfile::openRoot (ZBoolean aCreate)
{
  ZFUNCTRACE_DEVELOP ("ZProfile::openRoot(ZBoolean aCreate)");
  if (iRootHandle == 0 || (aCreate && iRootReadOnly))
      {
        closeRoot ();
        HKEY parentKey (0);
        ZString path;
        while (!parentKey)
            {
              path = iRoot;
              ZString token (splitPath (path));
              for (unsigned i = 0;
                   i < sizeof (sysHandles) / sizeof (SystemHandle); i++)
                if (token == sysHandles[i].iName)
                    {
                      parentKey = sysHandles[i].iHandle;
                      break;
                    }           // if
              if (!parentKey)
                iRoot =
                  ZString (sysHandles[0].iName) + (char) ZC_PATHSEPARATOR +
                  iRoot;
            }                   // while
        if (path.length ())
          iRootHandle = openHandle (parentKey, path, aCreate);
        else
          iRootHandle = parentKey;
        iRootReadOnly = !aCreate;
      }                         // if
}                               // openRoot
Example #19
0
ZFile::ZFile(const PathString& strPath, DWORD how) : 
    m_p(NULL)
{
	// BT - CSS - 12/8/2011 - Fixing 128 character path limit.
	DWORD dwDesiredAccess = GENERIC_READ;
	DWORD dwShareMode = FILE_SHARE_WRITE;
	DWORD dwCreationDisposition = OPEN_EXISTING;

	if((how & OF_WRITE) == OF_WRITE)
		dwDesiredAccess = GENERIC_WRITE;

	if((how & OF_SHARE_DENY_WRITE) == OF_SHARE_DENY_WRITE)
		dwShareMode = FILE_SHARE_READ;

	if((how & OF_CREATE) == OF_CREATE)
		dwCreationDisposition = CREATE_ALWAYS;

	// Unicode markers / wide format enables up to 32K path length. 
	PathString unicodePath("\\\\?\\");

	// If the path is relative, don't use unicode marker.
	if(strPath.Left(1) == ZString(".") || strPath.FindAny("//") == -1)
		unicodePath = strPath;
	else
		unicodePath += strPath;

	WCHAR* pszw = new WCHAR[unicodePath.GetLength() + 1];
    int result = MultiByteToWideChar(CP_ACP, 0, unicodePath, unicodePath.GetLength(), pszw, unicodePath.GetLength());
	pszw[result] = NULL;

	m_handle = CreateFileW(pszw, dwDesiredAccess,  dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);

	delete pszw;
	// BT - End fix.
}
Example #20
0
ZString TextScrollModel::getLineData( int line ) const
{
  if ( line < 0 || line >= lineCount() ) {
    return ZString();
  }
  return d->data[line].label;
}
Example #21
0
ZExport (int) ZProfile::valueType (const ZString & aValueName)
{
  ZFUNCTRACE_DEVELOP ("ZProfile::valueType(const ZString& aValueName)");
#ifdef ZC_WIN
  openPath (zFalse);

  DWORD dataType;
  if (!RegQueryValueEx ((HKEY) iPathHandle, aValueName, 0,
                        &dataType, NULL, NULL) == ERROR_SUCCESS)
    ZTHROWEXC (ValueNotFound);

  switch (dataType)
      {
      case 1:                  // String
      case 2:                  // ExpandString
        return String;
      case 3:                  // Binary
      case 7:                  // MultiString
        return Binary;
      case 4:                  // DWord
      case 5:                  // DWordBigEndian
        return Integer;
      default:;
      }                         // switch
  return Other;
#endif
#ifdef ZC_OS2
  ZString val (value (aValueName));
  if (ZString (val.asLong ()) == val)
    return Integer;
  if (val.isPrintable ())
    return String;
  return Binary;
#endif
}                               // valueType
Example #22
0
ZString ZString::strip(char target, bool modify){
    ZString tmp = data;
    for(unsigned i = 0; i < data.length(); ++i){
        if(data[i] == target){
            tmp = data.substr(i+1, data.length());
        } else {
            break;
        }
    }
    data = tmp.str();
    for(unsigned i = 0; i < data.length(); ++i){
        int curr = data.length() - 1 - i;
        if(data[curr] == target){
            tmp = data.substr(0, curr);
        } else {
            break;
        }
    }

    if(modify){
        data = tmp.str();
        return ZString(data);
    } else {
        return tmp;
    }
}
Example #23
0
ZString TextScrollModel::getLineMessage( int line ) const
{
  if ( line < 0 || line >= lineCount() ) {
    return ZString();
  }
  return d->data[line].message;
}
Example #24
0
    TRef<StringPane> AddGameStateTile(
        const ZString& strTitle, 
        Pane*          ppane
    ) {
        TRef<StringPane> pstringPane = new StringPane(ZString(), m_pfontTitles);

        m_pcolTiles->InsertAtBottom(
            new BorderPane(
                0, 
                1,
                s_colorBackground,
                new ColumnPane(
                    new ImagePane(m_pmodeler->LoadImage(strTitle, true)),
					new BorderPane(
						3,
						1,
						s_colorBackground,
						new ColumnPane(
							pstringPane,
							ppane
					)),
                    ppane
                )
            )
        );

        m_pcolTiles->InsertAtBottom(new FillPane(WinPoint(0, 1), s_colorLight));
        return pstringPane;
    }
Example #25
0
 ZString InsertHyphen(ZString strSource, int nOffset)
 {
     if (strSource.GetLength() < nOffset)
         return strSource;
     else
         return strSource.Left(nOffset) + ZString("-") + strSource.RightOf(nOffset);
 }
ZExport(ZPointerlist&) ZPointerlist::addAtPos(long aIndex, void* aPointer)
{
   ZFUNCTRACE_DEVELOP("ZPointerlist::addAtPos(long aIndex, void* aPointer");

   if (aIndex > iCount || aIndex < 0)
      ZTHROWEXC("Invalid index");

   if (iCount == iSize) {
      iSize = iSize ? iSize+iSize : 10;
      ZTRACE_DEVELOP("iSize "+ZString(iSize));
      void** newList = new void*[iSize];
      long i = 0;
      while (i < aIndex) {
         newList[i] = iList[i];
         i++;
      } // while
      newList[i++] = aPointer;
      while (i <= iCount) {
         newList[i] = iList[i-1];
         i++;
      } // while
      if (iList) delete [] iList;
      iList = newList;
   } else {
      for (long i = iCount; i > aIndex; i--)
         iList[i] = iList[i-1];
      iList[aIndex] = aPointer;
   } // if
   iCount++;
   return *this;
} // addAtPos
Example #27
0
ZExport (void) ZDateTime::setFormat (int aFormat)
{
  ZFUNCTRACE_DEVELOP ("ZDateTime::setFormat(int aFormat)");
  if (aFormat < 0 || aFormat > 2)
    ZTHROWEXC ("Invalid format (" + ZString (aFormat) + ")");
  iFormat = aFormat;
}                               // setFormat
Example #28
0
void ZFlyEmMisc::HackathonEvaluator::processNeuronTypeFile()
{
  ZJsonObject jsonObject;
  jsonObject.load(getNeuronInfoFile());

  const char *key;
  json_t *value;
  std::map<std::string, int> typeLabelMap;
  std::vector<int> bodyIdArray;
  std::vector<int> labelArray;
  int maxLabel = 0;
  ZJsonArray idJson;
  ZJsonArray labelJson;

  ZJsonObject_foreach(jsonObject, key, value) {
    int bodyId = ZString(key).firstInteger();
    ZJsonObject bodyJson(value, ZJsonValue::SET_INCREASE_REF_COUNT);
    std::string type = ZJsonParser::stringValue(bodyJson["Type"]);
    if (typeLabelMap.count(type) == 0) {
      typeLabelMap[type] = ++maxLabel;
    }

    int label = typeLabelMap[type];

    bodyIdArray.push_back(bodyId);
    labelArray.push_back(label);
    idJson.append(bodyId);
    labelJson.append(label);
  }
    //------------------------------------------------------------------------------
    void        SetCommandAction::Execute (void)
    {
        // get a pointer to the actual ship and the target
        IshipIGC*   pShip = static_cast<IshipIGC*> (static_cast<ImodelIGC*> (*m_pShip));
        ImodelIGC*  pTarget = static_cast<ImodelIGC*> (*m_pTarget);

        // the ship might not be there for any of a hundred reasons,
        // including that it was destroyed. If it's not there, we want
        // to skip setting its command.
        if (pShip)
        {
            // we want to use the pretty interface if this is a command for the player
            if ((pShip == trekClient.GetShip ()) and (m_command == c_cmdQueued))
            {
                TrekWindow* pWindow = GetWindow ();
                IshipIGC*   pCommander = g_pMission->GetCommanderShip ();
                ZString     strOrder = ZString (c_cdAllCommands[m_commandID].szVerb);
                if (pTarget)
                    strOrder = strOrder + " " + GetModelName (pTarget);
                pWindow->SetQueuedCommand (pCommander, m_commandID, pTarget);
                trekClient.PostText(true, "New orders from %s to %s: %s. Press [insert] to accept.", (const char*)GetModelName (pCommander), GetModelName (pShip), (const char*) strOrder);
            }
            else
                pShip->SetCommand (m_command, pTarget, m_commandID);
        }
    }
Example #30
0
ZString Value::Indent(int indent)
{
    static char* pchSpaces = "                                                                ";

    ZAssert(indent * 2 < 64);

    return ZString(pchSpaces, indent * 2);
}