Exemplo n.º 1
0
bool CSongState::EditSectionProperties(int Beat)
{
	int	iSection = m_Section.FindBeat(Beat);
	// if section not found, or section is implicit
	if (iSection < 0 || m_Section[iSection].Implicit())
		return(FALSE);
	CSong::CSection	sec(m_Section[iSection]);
	CString	name(m_SectionName[iSection]);
	CSectionPropsDlg	dlg(sec, name);
	if (dlg.DoModal() != IDOK)
		return(FALSE);
	// if section start or length changed
	if (sec.m_Start != m_Section[iSection].m_Start
	|| sec.m_Length != m_Section[iSection].m_Length) {
		if (!DeleteSection(Beat))	// delete section
			return(FALSE);
		MakeSectionMap();	// rebuild section map before inserting
		if (!InsertSection(sec, name))	// reinsert section
			return(FALSE);
	} else {	// start and length unchanged
		m_Section[iSection] = sec;
		m_SectionName[iSection] = name;
	}
	return(TRUE);
}
Exemplo n.º 2
0
BOOL CIni::CopySection(LPCTSTR lpSrcSection, LPCTSTR lpDestSection, BOOL bFailIfExist) const
{
	if (lpSrcSection == NULL || lpDestSection == NULL)
		return FALSE;

	if (_tcsicmp(lpSrcSection, lpDestSection) == 0)
		return FALSE;

	if (!IsSectionExist(lpSrcSection))
		return FALSE;

	if (bFailIfExist && IsSectionExist(lpDestSection))
		return FALSE;

	DeleteSection(lpDestSection);

	const DWORD SRC_LEN = GetKeyLines(lpSrcSection, NULL, 0);
	LPTSTR psz = new TCHAR[SRC_LEN + 2];
	//memset(psz, 0, sizeof(TCHAR) * (SRC_LEN + 2));
	GetKeyLines(lpSrcSection, psz, SRC_LEN);	
	const BOOL RES = ::WritePrivateProfileSection(lpDestSection, psz, m_pszPathName);
	delete [] psz;

	return RES;
}
Exemplo n.º 3
0
void CSunParser::DeleteSection(map<string, SSection*>* section) {
	map<string, SSection*>::iterator ui;

	for (ui = section->begin(); ui != section->end(); ui++) {
		DeleteSection(&ui->second->sections);
		delete ui->second;
	}
}
Exemplo n.º 4
0
//-------------------------------------------------------------------------------------------------
void KeyValues::Erase() {

	for( unsigned int i = 0; i < root.values.size(); i++ ) {
		DeleteSection( root.values[i].section );
	}
	
	Rewind();

}
Exemplo n.º 5
0
void FSequencer::DeleteSelectedItems()
{
	if (Selection.GetActiveSelection() == FSequencerSelection::EActiveSelection::KeyAndSection)
	{
		DeleteSelectedKeys();
		for (TWeakObjectPtr<UMovieSceneSection> SelectedSection : *Selection.GetSelectedSections())
		{
			DeleteSection(SelectedSection.Get());
		}
	}
	else if (Selection.GetActiveSelection() == FSequencerSelection::EActiveSelection::OutlinerNode)
	{
		SequencerWidget->DeleteSelectedNodes();
	}
}
Exemplo n.º 6
0
void CSunParser::Parse(char* buf, int size) {
	string thissection;
	SSection* section = NULL;

	char* endptr = buf + size;

	while (buf<=endptr) {
		if (buf[0] == '/' && buf[1] == '/') {
			// comment
			while ((buf != endptr) && *buf!='\n' && *buf!='\r') {
				buf++;
			}
		}
		else if (buf[0] == '/' && buf[1] == '*') {
			//comment
			while ((buf != endptr) && buf[0] != '*' || buf[1] != '/') {
				buf++;
			}
		}
		else if (*buf == '[') {
			// sectionname
			thissection = "";

			while (*(++buf) != ']') {
				thissection += *buf;
			}
		}
		else if (*buf == '{') {
			// section
			buf++;
			section = new SSection;
			transform(thissection.begin(), thissection.end(), thissection.begin(), (int (*)(int)) tolower);
			map<string, SSection*>::iterator ui = sections.find(thissection);

			if (ui != sections.end()) {
				DeleteSection(&ui->second->sections);
				delete ui->second;
			}
			sections[thissection] = section;
			buf = ParseSection(buf, endptr - buf, section);
		}

		// We can possible hit endptr from somewhere that increases, so don't go past it
		if (buf <= endptr)
			buf++;
	}
}
Exemplo n.º 7
0
bool IniFile::DeleteSectionsWithKeyValue(const string& keyName, const string& value)
{
	//First find sections containing the key
	SectionItor s_pos = mSections.begin();
    s_pos = mSections.begin();
	while (s_pos != mSections.end())
	{
		IniKey* key = GetKey(keyName, (*s_pos)->mName);
        {
        	if(key && key->mValue == value)
            {
           		//remove section
              	DeleteSection((*s_pos)->mName);
			    s_pos = mSections.begin();
            }
            else
            {
            	++s_pos;
            }
        }
    }
	return true;
}
Exemplo n.º 8
0
CSunParser::~CSunParser() {
	DeleteSection(&sections);
}
Exemplo n.º 9
0
char* CSunParser::ParseSection(char* buf, int size, SSection* section) {
	string thissection;
	char* endptr = buf + size;

	while (buf <= endptr) {

		if (buf[0] == '/' && buf[1] == '/') {
			// comment
			while (*buf != '\n' && *buf != '\r') {
				buf++;
			}
		}

		else if (buf[0] == '/' && buf[1] == '*') {
			// comment
			while (buf[0] != '*' || buf[1] != '/') {
				buf++;
			}
		}

		else if (*buf == '[') {
			// sectionname
			thissection = "";

			while (*(++buf) != ']') {
				thissection += *buf;
			}
		}

		else if (*buf == '{') {
			// section
			buf++;
			SSection* newsection = new SSection;
			transform(thissection.begin(), thissection.end(), thissection.begin(), (int (*)(int)) tolower);
			map<string, SSection*>::iterator ui = section->sections.find(thissection);

			if (ui != section->sections.end()) {
				DeleteSection(&ui->second->sections);
				delete ui->second;
			}

			section->sections[thissection] = newsection;
			buf = ParseSection(buf, endptr - buf, newsection);
		}

		else if (*buf == '}') {
			// endsection
			// buf++;
			return buf;
		}

		else if (*buf >= '0' && *buf <= 'z') {
			string name;
			string value;

			while (*buf != '=') {
				name += *buf;
				buf++;
			}

			buf++;

			while (*buf != ';') {
				value += *buf;
				buf++;
			}

			transform(name.begin(), name.end(), name.begin(), (int (*)(int)) tolower);
			section->values[name] = value;
		}

		buf++;
	}

	return buf;
}
Exemplo n.º 10
0
int main(int argc, char ** argv)
{
  google::SetUsageMessage(
      "Takes OSM XML data from stdin and creates data and index files in several passes.");

  google::ParseCommandLineFlags(&argc, &argv, true);

  Platform & pl = GetPlatform();

  if (!FLAGS_user_resource_path.empty())
    pl.SetResourceDir(FLAGS_user_resource_path);

  string const path =
      FLAGS_data_path.empty() ? pl.WritableDir() : my::AddSlashIfNeeded(FLAGS_data_path);

  feature::GenerateInfo genInfo;
  genInfo.m_intermediateDir = FLAGS_intermediate_data_path.empty() ? path
                            : my::AddSlashIfNeeded(FLAGS_intermediate_data_path);
  genInfo.m_targetDir = genInfo.m_tmpDir = path;

  /// @todo Probably, it's better to add separate option for .mwm.tmp files.
  if (!FLAGS_intermediate_data_path.empty())
  {
    string const tmpPath = genInfo.m_intermediateDir + "tmp" + my::GetNativeSeparator();
    if (pl.MkDir(tmpPath) != Platform::ERR_UNKNOWN)
      genInfo.m_tmpDir = tmpPath;
  }

  genInfo.m_osmFileName = FLAGS_osm_file_name;
  genInfo.m_failOnCoasts = FLAGS_fail_on_coasts;
  genInfo.m_preloadCache = FLAGS_preload_cache;

  genInfo.m_versionDate = static_cast<uint32_t>(FLAGS_planet_version);

  if (!FLAGS_node_storage.empty())
    genInfo.SetNodeStorageType(FLAGS_node_storage);
  if (!FLAGS_osm_file_type.empty())
    genInfo.SetOsmFileType(FLAGS_osm_file_type);

  // Generating intermediate files
  if (FLAGS_preprocess)
  {
    LOG(LINFO, ("Generating intermediate data ...."));
    if (!GenerateIntermediateData(genInfo))
    {
      return -1;
    }
  }

  // load classificator only if necessary
  if (FLAGS_make_coasts || FLAGS_generate_features || FLAGS_generate_geometry ||
      FLAGS_generate_index || FLAGS_generate_search_index ||
      FLAGS_calc_statistics || FLAGS_type_statistics || FLAGS_dump_types || FLAGS_dump_prefixes ||
      FLAGS_check_mwm)
  {
    classificator::Load();
    classif().SortClassificator();
  }

  // Generate dat file
  if (FLAGS_generate_features || FLAGS_make_coasts)
  {
    LOG(LINFO, ("Generating final data ..."));

    genInfo.m_splitByPolygons = FLAGS_split_by_polygons;
    genInfo.m_createWorld = FLAGS_generate_world;
    genInfo.m_makeCoasts = FLAGS_make_coasts;
    genInfo.m_emitCoasts = FLAGS_emit_coasts;
    genInfo.m_fileName = FLAGS_output;
    genInfo.m_genAddresses = FLAGS_generate_addresses_file;

    if (!GenerateFeatures(genInfo))
      return -1;

    if (FLAGS_generate_world)
    {
      genInfo.m_bucketNames.push_back(WORLD_FILE_NAME);
      genInfo.m_bucketNames.push_back(WORLD_COASTS_FILE_NAME);
    }
  }
  else
  {
    if (!FLAGS_output.empty())
      genInfo.m_bucketNames.push_back(FLAGS_output);
  }

  // Enumerate over all dat files that were created.
  size_t const count = genInfo.m_bucketNames.size();
  for (size_t i = 0; i < count; ++i)
  {
    string const & country = genInfo.m_bucketNames[i];
    string const datFile = my::JoinFoldersToPath(path, country + DATA_FILE_EXTENSION);

    if (FLAGS_generate_geometry)
    {
      int mapType = feature::DataHeader::country;
      if (country == WORLD_FILE_NAME)
        mapType = feature::DataHeader::world;
      if (country == WORLD_COASTS_FILE_NAME)
        mapType = feature::DataHeader::worldcoasts;

      // If error - move to next bucket without index generation.

      LOG(LINFO, ("Generating result features for", country));
      if (!feature::GenerateFinalFeatures(genInfo, country, mapType))
        continue;

      LOG(LINFO, ("Generating offsets table for", datFile));
      if (!feature::BuildOffsetsTable(datFile))
        continue;
    }

    if (FLAGS_generate_index)
    {
      LOG(LINFO, ("Generating index for", datFile));

      if (!indexer::BuildIndexFromDatFile(datFile, FLAGS_intermediate_data_path + country))
        LOG(LCRITICAL, ("Error generating index."));
    }

    if (FLAGS_generate_search_index)
    {
      LOG(LINFO, ("Generating search index for ", datFile));

      if (!indexer::BuildSearchIndexFromDatFile(datFile, true))
        LOG(LCRITICAL, ("Error generating search index."));
    }
  }

  // Create http update list for countries and corresponding files
  if (FLAGS_generate_update)
  {
    LOG(LINFO, ("Updating countries file..."));
    update::UpdateCountries(path);
  }

  string const datFile = path + FLAGS_output + DATA_FILE_EXTENSION;

  if (FLAGS_calc_statistics)
  {
    LOG(LINFO, ("Calculating statistics for ", datFile));

    stats::FileContainerStatistic(datFile);
    stats::FileContainerStatistic(datFile + ROUTING_FILE_EXTENSION);

    stats::MapInfo info;
    stats::CalcStatistic(datFile, info);
    stats::PrintStatistic(info);
  }

  if (FLAGS_type_statistics)
  {
    LOG(LINFO, ("Calculating type statistics for ", datFile));

    stats::MapInfo info;
    stats::CalcStatistic(datFile, info);
    stats::PrintTypeStatistic(info);
  }

  if (FLAGS_dump_types)
    feature::DumpTypes(datFile);

  if (FLAGS_dump_prefixes)
    feature::DumpPrefixes(datFile);

  if (FLAGS_dump_search_tokens)
    feature::DumpSearchTokens(datFile);

  if (FLAGS_unpack_mwm)
    UnpackMwm(datFile);

  if (!FLAGS_delete_section.empty())
    DeleteSection(datFile, FLAGS_delete_section);

  if (FLAGS_generate_packed_borders)
    borders::GeneratePackedBorders(path);

  if (FLAGS_check_mwm)
    check_model::ReadFeatures(datFile);

  if (!FLAGS_osrm_file_name.empty() && FLAGS_make_routing)
    routing::BuildRoutingIndex(path, FLAGS_output, FLAGS_osrm_file_name);

  if (!FLAGS_osrm_file_name.empty() && FLAGS_make_cross_section)
    routing::BuildCrossRoutingIndex(path, FLAGS_output, FLAGS_osrm_file_name);

  return 0;
}
Exemplo n.º 11
0
BOOL CIni::MoveSection(LPCTSTR lpSrcSection, LPCTSTR lpDestSection, BOOL bFailIfExist) const
{
	return CopySection(lpSrcSection, lpDestSection, bFailIfExist)
		&& DeleteSection(lpSrcSection);
}
Exemplo n.º 12
0
//-------------------------------------------------------------------------------------------------
void KeyValues::DeleteSection( Section *section ) {
	if( !section ) return;
	for( unsigned int i = 0; i < section->values.size(); i++ ) {
		DeleteSection( section->values[i].section );
	}
}
Exemplo n.º 13
0
char *CSunParser::ParseSection(char *buf, int size, SSection *section)
{
    ////L("CSunParser::ParseSection(buf, " << size << ", " << section << ")" << endl);
	string thissection;

//	int se = 0; //for section start/end errorchecking

	char *endptr = buf+size;

	while(buf<=endptr)
	{

		if(buf[0]=='/' && buf[1]=='/') //comment
		{
			while(*buf!='\n' && *buf!='\r')
			{

				buf++;
			}
		}
		else if(buf[0]=='/' && buf[1]=='*') //comment
		{
			while(buf[0]!='*' || buf[1]!='/')
			{

				buf++;
			}
		}
		else if(*buf == '[') //sectionname
		{
			thissection = "";
			while(*(++buf)!=']')
			{

				thissection += *buf;
			}
		}
		else if(*buf == '{') //section
		{
			buf++;
			SSection *newsection = new SSection;
			transform(thissection.begin(), thissection.end(), thissection.begin(), (int (*)(int))tolower);
			map<string, SSection*>::iterator ui=section->sections.find(thissection);
			if(ui!=section->sections.end()){
//				MessageBox(0,"Overwrote earlier section in sunparser",thissection.c_str(),0);
                ////L("Sun Parsing Error: Overwrote earlier section in sunparser: " << thissection << endl);
				DeleteSection(&ui->second->sections);
				delete ui->second;
			}
			section->sections[thissection] = newsection;
			buf = ParseSection(buf, endptr-buf, newsection);
		}
		else if(*buf == '}') //endsection
		{
			//buf++;
			return buf;
		}
		else if(*buf >= '0' && *buf <= 'z')
		{
			string name;
			string value;

			while(*buf != '=')
			{
				name += *buf;
				buf++;
			}
			buf++;
			while(*buf != ';')
			{
				value += *buf;
				buf++;
			}
			transform(name.begin(), name.end(), name.begin(), (int (*)(int))tolower);
			////L("Attempting " << name << " = " << value << endl);
			section->values[name] = value;
			////L(name << " = " << value << endl);
		}

		buf++;
	}

	return buf;
}
Exemplo n.º 14
0
CSunParser::~CSunParser()
{
    ////L("CSunParser::~CSunParser()");
	DeleteSection(&sections);
	////L("~");
}
Exemplo n.º 15
0
void CSunParser::Parse(char *buf, int size)
{
    ////L("CSunParser::Parse(buf, " << size << ")" << endl);
	string thissection;
	SSection *section = NULL;

	//vector<map<string,SSection*>*> sectionlist;
	//sectionlist.push_back(&sections);

//	int se = 0; //for section start/end errorchecking

	char *endptr = buf+size;

	while(buf<=endptr)
	{

		if(buf[0]=='/' && buf[1]=='/') //comment
		{
			while((buf != endptr) && *buf!='\n' && *buf!='\r')
			{

				buf++;
			}
		}
		else if(buf[0]=='/' && buf[1]=='*') //comment
		{
			while((buf != endptr) && buf[0]!='*' || buf[1]!='/')
			{

				buf++;
			}
		}
		else if(*buf == '[') //sectionname
		{
			thissection = "";
			while(*(++buf)!=']')
			{

				thissection += *buf;
			}
		}
		else if(*buf == '{') //section
		{
			buf++;
			section = new SSection;
			transform(thissection.begin(), thissection.end(), thissection.begin(), (int (*)(int))tolower);
			map<string, SSection*>::iterator ui=sections.find(thissection);
			if(ui!=sections.end()){
//				MessageBox(0,"Overwrote earlier section in sunparser",thissection.c_str(),0);
                ////L("Sun Parsing Error: Overwrote earlier section in sunparser: " << thissection << endl);
				DeleteSection(&ui->second->sections);
				delete ui->second;
			}
			sections[thissection] = section;
			buf = ParseSection(buf, endptr-buf, section);

		}

		// We can possible hit endptr from somewhere that increases, so don't go past it
		if (buf <= endptr)
			buf++;
	}
	////L("Finished Parsing" << endl);
}