string simplifyPath(string path) {
     // Start typing your C/C++ solution below
     // DO NOT write int main() function
     if(path.length() == 0)
         return NULL;
     char slash = '/';
     if(path.length() == 1 && path[0] == slash)
         return path;
     string result;
     vector<string> splits;
     splits = getStrings(path);
     vector<string>::iterator iter;
     if(splits.size() == 0)
     {
         result = "/";
         return result;
     }
     for(iter = splits.begin(); iter!=splits.end(); iter++)
     {
         if(*iter != ".")
             result = result + '/' + *iter;
     }
     if(result == "")
         result = "/";
     return result;
 }
Exemple #2
0
 static void getInts(const char *str, AzByte dlm, AzIntArr *ia) {
   ia->reset(); 
   AzStrPool sp; 
   getStrings(str, dlm, &sp); 
   int ix; 
   for (ix = 0; ix < sp.size(); ++ix) {
     ia->put(atol(sp.c_str(ix))); 
   }
 }
Exemple #3
0
 static void getFloats(const char *str, AzByte dlm, AzDvect *v) {
   AzIFarr ifa; 
   AzStrPool sp; 
   getStrings(str, dlm, &sp); 
   int ix; 
   for (ix = 0; ix < sp.size(); ++ix) {
     ifa.put(-1, atof(sp.c_str(ix))); 
   }
   v->reform(ifa.size()); 
   for (ix = 0; ix < ifa.size(); ++ix) {
     v->set(ix, ifa.get(ix)); 
   }
 }
Exemple #4
0
int Layout::geStringCourse( int aString, bool & aOutOctave ) const
{
  aOutOctave = false;
  switch ( mKind )
  {
  case Kind::Renaissance:
    if ( aString == 1 )
      return 1;
    else if ( aString > 1 && aString <= getStrings() )
    {
      int course = aString / 2 + 1;
      if ( course > 5 && ( aString % 2 == 0 ) )
      {
        aOutOctave = true;
      }
      return course;
    }
    else
      return 0;
  case Kind::Baroque:
    if ( aString == 1 || aString == 2 )
      return aString;
    else if ( aString > 2 && aString <= getStrings() )
    {
      int course = ( aString - 3 ) / 2 + 3;
      if ( course > 5 && ( aString % 2 == 1 ) )
      {
        aOutOctave = true;
      }
      return course;
    }
    else
      return 0;
  default:
    return 0;
  }
}
Exemple #5
0
frts::Application::LoadConfiguration frts::Application::readLoadFile(const std::string& filePath) const
{
    YamlConfigParser parser;
    auto node = parser.parseFile(filePath);

    LoadConfiguration result;
    result.plugins = node->getStrings("plugins");
    result.renderModules = node->getStrings("renderModules");
    result.shutdownModules = node->getStrings("shutdownModules");
    result.startupModules = node->getStrings("startupModules");
    result.updateModules = node->getStrings("updateModules");
    result.utilities = node->getStrings("utilities");
    result.configurations = node->getStrings("configurations");
    return result;
}
Exemple #6
0
  /*---  (NOTE) This doesn't skip preceding white characters.  ---*/
  static const AzByte *getString(const AzByte **wpp, const AzByte *data_end, 
                                   AzByte wdlm, int *byte_len); 
  static void getString(const AzByte **wpp, const AzByte *data_end, 
                        AzByte wdlm, AzBytArr *string) 
  {
    int str_len; 
    const AzByte *str = getString(wpp, data_end, wdlm, &str_len); 
    string->concat(str, str_len); 
  }

  static void getStrings(const AzByte *data, int data_len, 
                         AzStrPool *sp_tokens); 

  static void getStrings(const AzByte *data, int len, 
                         AzByte dlm, 
                         AzStrPool *sp_out); /* output */
  inline static void getStrings(const char *str, AzByte dlm, AzStrPool *sp_out) {
    if (str == NULL) return; 
    getStrings((AzByte *)str, Az64::cstrlen(str), dlm, sp_out); 
  }
  static void getStrings(const AzByte *data, const AzByte *data_end, 
                         AzByte dlm, 
                         AzDataArray<AzBytArr> *aStr_out); /* output */
  inline static void getStrings(const char *str, AzByte dlm, 
                                AzDataArray<AzBytArr> *aStr_out) /* output */
  {
    if (str == NULL) return; 
    getStrings((AzByte *)str, (AzByte *)(str + strlen(str)), dlm, aStr_out); 
  }
Exemple #7
0
  /*---  (NOTE) This doesn't skip preceding white characters.  ---*/
  static const AzByte *getString(const AzByte **wpp, const AzByte *data_end, 
                                   AzByte wdlm, int *byte_len); 
  static void getString(const AzByte **wpp, const AzByte *data_end, 
                        AzByte wdlm, AzBytArr *string) 
  {
    int str_len; 
    const AzByte *str = getString(wpp, data_end, wdlm, &str_len); 
    string->concat(str, str_len); 
  }

  static void getStrings(const AzByte *data, int data_len, 
                         AzStrPool *sp_tokens); 

  static void getStrings(const AzByte *data, int len, 
                         AzByte dlm, 
                         AzStrPool *sp_out); /* output */
  inline static void getStrings(const char *str, AzByte dlm, AzStrPool *sp_out) {
    if (str == NULL) return; 
    getStrings((AzByte *)str, Az64::cstrlen(str), dlm, sp_out); 
  }
AssetManagerGlue::StringBlock*
AssetManagerGlue::XmlBlock::nativeGetStringBlock()
{
	return new StringBlock(&getStrings(), false);
}
Json::Value* MappedValues::toJson()
{

	Json::Value* res = new Json::Value;
	Json::Value& root = *res;
	Json::Value floats, ints, uints, strings, vector2s, vector3s, vector4s, matrix2s, matrix3s, matrix4s, textures;

	for (auto& a : getFloats()) {
		floats[a.first] = a.second;
	}

	for (auto& a : getInts()) {
		ints[a.first] = a.second;
	}

	for (auto& a : getUints()) {
		uints[a.first] = a.second;
	}

	for (auto& a : getStrings()) {
		strings[a.first] = a.second.c_str();
	}

	for (auto& a : getVector2s()) {
		vector2s[a.first].append(a.second.x);
		vector2s[a.first].append(a.second.y);
	}

	for (auto& a : getVector3s()) {
		vector3s[a.first].append(a.second.x);
		vector3s[a.first].append(a.second.y);
		vector3s[a.first].append(a.second.z);
	}

	for (auto& a : getVector4s()) {
		vector4s[a.first].append(a.second.x);
		vector4s[a.first].append(a.second.y);
		vector4s[a.first].append(a.second.z);
		vector4s[a.first].append(a.second.w);
	}

	for (auto& a : getMatrix2s()) {
		for (U32 i = 0; i < 4; ++i) matrix2s[a.first].append(a.second.getElement(i));
	}

	for (auto& a : getMatrix3s()) {
		for (U32 i = 0; i < 9; ++i) matrix3s[a.first].append(a.second.getElement(i));
	}

	for (auto& a : getMatrix4s()) {
		for (U32 i = 0; i < 16; ++i) matrix4s[a.first].append(a.second.getElement(i));
	}

	for (auto& a : getTextures()) {

		textures[a.first] = a.second->save();
	}




	root["Floats"] = floats;
	root["Ints"] = ints;
	root["Uints"] = uints;
	root["Strings"] = strings;
	root["Vector2s"] = vector2s;
	root["Vector3s"] = vector3s;
	root["Vector4s"] = vector4s;
	root["Matrix2s"] = matrix2s;
	root["Matrix3s"] = matrix3s;
	root["Matrix4s"] = matrix4s;
	root["Textures"] = textures;

	return res;
}
Exemple #10
0
QStringList StringHandler::getStrings(QString value)
{
  return getStrings(value, '{', '}');
}
Exemple #11
0
int ui_doinstall(HANDLE hFile,int offset,header *head, section *sec, entry *ent, uninstall_header *uhead)
{
  TCHAR tmpbuf[MAX_PATH];
  int ret = 3;
  m_hFile=hFile;
  m_offset=offset;
  m_section=sec;
  m_entry=ent;
  m_header=head;

  if (!uhead) {
	  if (noisy) {
		  noisy=!(head->silent_install);
	  } else {
		  head->silent_install = !noisy;
	  }
	  /* Setup localized strings */
	  if ((g_strings = getStrings(NULL)) == NULL) {
		  GETRESOURCE(tmpbuf, JAVAWS_ERROR_STRINGTABLE);
		  if (noisy) MessageBox(NULL,tmpbuf,g_caption,MB_OK|MB_ICONWARNING);
	  }
	  _tcscpy(tmpbuf, m_header->name);
	  process_string(m_header->name, tmpbuf, NULL);
	  _tcscpy(tmpbuf, m_header->licensetext);
	  process_string(m_header->licensetext, tmpbuf, NULL);
	  _tcscpy(tmpbuf, m_header->componenttext);
	  process_string(m_header->componenttext, tmpbuf, NULL);
	  _tcscpy(tmpbuf, m_header->text);
	  process_string(m_header->text, tmpbuf, NULL);
  }

#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
  m_uninstheader=uhead;
  if (uhead)
  {
	  INT32 args[] = { (INT32)m_uninstheader->name };
	  g_strings = getStrings(NULL);
	  _tcscpy(tmpbuf, m_uninstheader->uninstalltext);
	  process_string(m_uninstheader->uninstalltext, tmpbuf, NULL);
	  GETRESOURCE2(tmpbuf, JAVAWS_MESSAGE_UNINSTALL, args);
      wsprintf(g_caption,tmpbuf);
      return DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST),GetDesktopWindow(),DialogProcUninstall);
  }
  else
#endif
  {
    TCHAR buf[MAX_PATH];
    int st=0;

    state_install_directory[0]=0;
    if (head->install_reg_key[0])
    {
      HKEY hKey;
		  if ( RegOpenKeyEx((HKEY)head->install_reg_rootkey,head->install_reg_key,0,KEY_READ,&hKey) == ERROR_SUCCESS)
      {
			  int l = sizeof(buf);
			  int t=REG_SZ;
        if (RegQueryValueEx(hKey,head->install_reg_value,NULL,&t,buf,&l ) == ERROR_SUCCESS && t == REG_SZ && buf[0])
			  {
          LPTSTR e;
          LPTSTR p=buf;
          while (*p && *p != _T('\"')) p=CharNext(p);
          if (*p)
          {
            LPTSTR p2;
			p=CharNext(p);
			p2 = p;
            while (*p2 && *p2 != _T('\"')) p2=CharNext(p2);
            if (*p2)
            {
              *p2=0;
            }
            else p=buf;
          }
          else p=buf; 
          // p is the path now, check for .exe extension
          e=p;
          while (*e) e=CharNext(e);
          while (e>p && *e != _T('.') && *e != _T('\\')) e=CharPrev(p, e);
          if (*e ==_T('.'))
          {
            if ((e[1] == _T('e') || e[1]==_T('E')) &&
                (e[2] == _T('x') || e[2]==_T('X')) &&
                (e[3] == _T('e') || e[3]==_T('E')))        // check extension
            {
              DWORD d;
              e[4]=0;
              d=GetFileAttributes(p);               // get the file attributes
              if (d == 0xFFFFFFFFF || !(d&FILE_ATTRIBUTE_DIRECTORY)) // if not exists, or not directory, then remove suffix
              {
				while (e>p && *e != _T('\\')) e=CharPrev(p, e);
                if (*e == _T('\\')) *e=0;
              }
            }
          }


          _tcscpy(state_install_directory,buf);
        }
			  RegCloseKey(hKey);
      }
    }

    if (!state_install_directory[0]) 
    {
      _tcscpy(state_install_directory,head->install_directory);
#ifdef NSIS_CONFIG_WINAMPHACKCHECK
#warning NSIS_CONFIG_WINAMPHACKCHECK defined, this section NOT internationalized, proceed with caution!
      if (!mini_stricmp(state_install_directory,"$PROGRAMFILES\\Winamp"))
      {
        HKEY hKey;
		    if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Winamp",0,KEY_READ,&hKey) == ERROR_SUCCESS)
		    {
			    int l = sizeof(buf);
			    int t=REG_SZ;
			    if (RegQueryValueEx(hKey,"UninstallString",NULL,&t,buf,&l ) == ERROR_SUCCESS && t == REG_SZ)
			    {
				    char *p=buf+mini_strlen(buf);
				    while (p >= buf && *p != '\\') p--;
				    if ( p >= buf)
				    {
					    char *i=buf;
					    *p=0;
					    while (*i == ' ' || *i == '\"') i++;
					    mini_strcpy(state_install_directory,i);
              st=1;
				    }
			    }
			    RegCloseKey(hKey);
		    }
      }
#endif

      if (!st && !process_string(buf,state_install_directory,NULL)) {
        _tcscpy(state_install_directory,buf);
	  }
    }

	{
		INT32 args[] = { (INT32)head->name };
		GETRESOURCE2(tmpbuf, JAVAWS_MESSAGE_SETUP, args);
		wsprintf(g_caption,"%s Setup",head->name);
	}
#ifdef NSIS_CONFIG_LOG
    if (head->silent_install==2) 
    {
      wsprintf(g_log_file,"%s%sinstall.log",state_install_directory,state_install_directory[mini_strlen(state_install_directory)-1]=='\\'?"":"\\");    
      log_dolog=1;
    }
#endif

    if (!head->silent_install && autoinstall != 1) {
      ret = DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST),
		       GetDesktopWindow(),DialogProc);
      /* if ret was 3 we only showed the license agreement, */
      /* so continue as if we are doing an autoinstall and  */
      /* run the install thread without a UI.               */
      if (ret != 3) return ret;
    }
    m_section[0].default_state=0x80000000;
    return install_thread(NULL);
  }
}