コード例 #1
0
ファイル: SectionHDF5.cpp プロジェクト: cgars/nix
bool SectionHDF5::deleteSection(const string &name_or_id) {
    boost::optional<H5Group> g = section_group();
    bool deleted = false;

    if (g) {
        // call deleteSection on sections to trigger recursive call to all sub-sections
        if (hasSection(name_or_id)) {
            // get instance of section about to get deleted
            Section section = getSection(name_or_id);
            // loop through all child sections and call deleteSection on them
            for (auto &child : section.sections()) {
                section.deleteSection(child.id());
            }
            // if hasSection is true then section_group always exists
            deleted = g->removeAllLinks(section.name());
        }
    }

    return deleted;
}
コード例 #2
0
ファイル: Section.cpp プロジェクト: eightcien/lldb
SectionSP
SectionList::FindSectionContainingLinkedFileAddress (addr_t vm_addr, uint32_t depth) const
{
    SectionSP sect_sp;
    const_iterator sect_iter;
    const_iterator end = m_sections.end();
    for (sect_iter = m_sections.begin(); sect_iter != end && sect_sp.get() == NULL; ++sect_iter)
    {
        Section *sect = sect_iter->get();
        if (sect->ContainsLinkedFileAddress (vm_addr))
        {
            sect_sp = *sect_iter;
        }
        else if (depth > 0)
        {
            sect_sp = sect->GetChildren().FindSectionContainingLinkedFileAddress (vm_addr, depth - 1);
        }
    }
    return sect_sp;
}
コード例 #3
0
void mem_conf(std::string memtype, int option) {
	std::string tmp;
	Section* sec = control->GetSection("dos");
	Section_prop * section=static_cast<Section_prop *>(sec); 
	if (!option) {
		tmp = section->Get_bool(memtype) ? "false" : "true";
	} else {
		switch (option) {
			case 1: tmp = "true"; break;
			case 2: tmp = "false"; break;
			case 3: tmp = "emsboard"; break;
			case 4: tmp = "emm386"; break;
			default: return;
		}
	}
	if(sec) {
		memtype += "=" + tmp;
		sec->HandleInputline(memtype);
	}
}
コード例 #4
0
ファイル: action.cpp プロジェクト: Aegisub/Athenasub
/////////////////////////////////
// Create anti-action for insert
Action ActionModify::GetAntiAction() const
{
	// Get section and original line
	Section sect = GetSection(section);
	Entry oldEntry = sect->GetEntry(lineNumber);

	// Try to get a delta
	DeltaCoder deltaCoder = oldEntry->GetDeltaCoder();
	if (deltaCoder) {
		VoidPtr _delta;
		if (entry) _delta = deltaCoder->EncodeDelta(entry,oldEntry,!noTextFields);
		else _delta = deltaCoder->EncodeReverseDelta(delta,oldEntry);
		return Action(new ActionModify(GetModel(),_delta,lineNumber,section));
	}

	// Store the whole original line
	else {
		return Action(new ActionModify(GetModel(),oldEntry,lineNumber,section,noTextFields));
	}
}
コード例 #5
0
ファイル: IniFile.cpp プロジェクト: Karkasos/Core
		IniFile* IniFile::ReadIniFile(CStr fileName)
		{
			Assert(fileName);
			CStr braceOpen = Text("[");
			//CStr braceClose = Text("]");
			CStr equal = Text("=");
			IniFile* iniFile;
			String::StrPtrVec* lines;
			String::StrPtrVec::Element* it;
			Section section;
			Int index;
			KeyValue keyValue;

			iniFile = new IniFile();
			lines = TextFile::ReadLines(fileName);

			for(it = lines->Begin(); it < lines->End(); ++it)
			{
				String& line = **it;
				if(line.TrimLeft().StartsWith(braceOpen))
				{
					if(!section.IsEmpty())
					{
						iniFile->SectionList.Add(section);
						section.Clear();
					}
					section.Name = line;
				}
				else if((index = line.IndexOf(equal)) != -1)
				{
					if(!section.Name.IsEmpty())
					{
						keyValue.Key = line.SubString(0U, index - 2).Trim();
						keyValue.Value = line.SubString(index - 1, line.Length() - index - 1).Trim();
						section.KeyValueList.Add(keyValue);
					}
				}
			}

			return iniFile;
		}
コード例 #6
0
 bool visit_Section(Section & s)
 {
     str_type base_dir = this->_base_dir;
     if(s.has_key("__base_dir__"))
     {
         str_type section_base_dir = s.at("__base_dir__");
         if(section_base_dir.size() > 0)
         {
             base_dir = section_base_dir;
         }
     }
     str_type norm_base_dir = this->_normpath(base_dir);
     //std::cout << "s<" << s << "> " << base_dir << " : " << this->_base_dir << std::endl;
     if(base_dir.size() > 0 && norm_base_dir != this->_base_dir)
     {
         ResetBaseDirVisitor reset_base_dir_visitor(base_dir, this->_reset);
         s.accept(reset_base_dir_visitor);
         return false;
     }
     return true;
 }
コード例 #7
0
void
ConfigDocumentXML::parse()
{
  QDomNode n = document_.firstChild();
  if (!n.isNull()) {
    QDomNode n1 = n.firstChild();
    QListViewItem * pre = NULL;
    while (!n1.isNull()) {
      QDomElement e = n1.toElement();
      if (!e.isNull() &&
	  e.tagName() == Section::XML_TAG) {
	Section * section =
	  new Section(e, 
		      listViewItem(), pre, 
		      this, e.attribute("name"));
	pre = section->listViewItem();
      }
      n1 = n1.nextSibling();
    }
  }
}
コード例 #8
0
ファイル: COFFObjcopy.cpp プロジェクト: jamboree/llvm
static void addGnuDebugLink(Object &Obj, StringRef DebugLinkFile) {
  uint32_t StartRVA = getNextRVA(Obj);

  std::vector<Section> Sections;
  Section Sec;
  Sec.setOwnedContents(createGnuDebugLinkSectionContents(DebugLinkFile));
  Sec.Name = ".gnu_debuglink";
  Sec.Header.VirtualSize = Sec.getContents().size();
  Sec.Header.VirtualAddress = StartRVA;
  Sec.Header.SizeOfRawData = alignTo(Sec.Header.VirtualSize,
                                     Obj.IsPE ? Obj.PeHeader.FileAlignment : 1);
  // Sec.Header.PointerToRawData is filled in by the writer.
  Sec.Header.PointerToRelocations = 0;
  Sec.Header.PointerToLinenumbers = 0;
  // Sec.Header.NumberOfRelocations is filled in by the writer.
  Sec.Header.NumberOfLinenumbers = 0;
  Sec.Header.Characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA |
                               IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_DISCARDABLE;
  Sections.push_back(Sec);
  Obj.addSections(Sections);
}
コード例 #9
0
ファイル: config-file.cpp プロジェクト: AdamRi/scummvm-pink
void ConfigFile::setKey(const String &key, const String &section, const String &value) {
	assert(isValidName(key));
	assert(isValidName(section));
	// TODO: Verify that value is valid, too. In particular, it shouldn't
	// contain CR or LF...

	Section *s = getSection(section);
	if (!s) {
		KeyValue newKV;
		newKV.key = key;
		newKV.value = value;

		Section newSection;
		newSection.name = section;
		newSection.keys.push_back(newKV);

		_sections.push_back(newSection);
	} else {
		s->setKey(key, value);
	}
}
コード例 #10
0
ファイル: RacingChars.cpp プロジェクト: teju85/programming
 void printPath() const {
     int len = (int)size();
     int pe = -1;
     for(int i=0;i<len;++i) {
         Section* s = at(i);
         int se = positions[i];
         if(pe == -1) {
             pe = se;
         }
         if(se == pe) {
             s->print('|', se);
         }
         else if(se < pe) {
             s->print('/', se);
         }
         else {
             s->print('\\', se);
         }
         pe = se;
     }
 }
コード例 #11
0
ファイル: Section.cpp プロジェクト: ruoqi/poputar
Section* Section::createSection(SectionInfo* sectionInfo,int index,int type,int p_index,int s_index){
    Section *item = new Section();
    if(item && item->init()){
    
        PlayConfig* playConfig = (PlayConfig*)poptGlobal->gni->getConfig();
        
        //音乐信息
        MusicModel* musicModel = playConfig->musicModel;
        //小节拍数
        int beatFlag = musicModel->getBeatFlag();
        //单元宽度,拍与拍之间的距离
        float unitWidth = playConfig->unitWidth;
        //小节总宽度
        item->sectionWidth = unitWidth*beatFlag;
        float sectionX = item->sectionWidth*(float)(index-1);
        item->p_index = p_index;
        item->s_index = s_index;
        
        item->sectionIndex = index;
        item->type = type;
        item->playConfig = playConfig;
        item->setAnchorPoint(Vec2::ZERO);
        item->setPosition(Vec2(sectionX,0));
        item->loadMusical(sectionInfo);
        item->autorelease();
        
        return item;
    }
    CC_SAFE_DELETE(item);
    return nullptr;
}
コード例 #12
0
ファイル: SHAMapStoreImp.cpp プロジェクト: onedot618/rippled
std::shared_ptr <NodeStore::Backend>
SHAMapStoreImp::makeBackendRotating (std::string path)
{
    boost::filesystem::path newPath;
    Section parameters = setup_.nodeDatabase;

    if (path.size())
    {
        newPath = path;
    }
    else
    {
        boost::filesystem::path p = get<std::string>(parameters, "path");
        p /= dbPrefix_;
        p += ".%%%%";
        newPath = boost::filesystem::unique_path (p);
    }
    parameters.set("path", newPath.string());

    return NodeStore::Manager::instance().make_Backend (parameters, scheduler_,
            nodeStoreJournal_);
}
コード例 #13
0
ファイル: Section.cpp プロジェクト: carlokok/lldb
void
SectionList::BuildRangeCache() const
{
    m_range_cache.Clear();
    
    for (collection::size_type idx = 0, last_idx = m_sections.size();
         idx < last_idx;
         ++idx)
    {
        Section *sect = m_sections[idx].get();
        
        addr_t linked_file_address = sect->GetLinkedFileAddress();
        
        if (linked_file_address != LLDB_INVALID_ADDRESS)
            m_range_cache.Append(SectionRangeCache::Entry(linked_file_address, sect->GetByteSize(), idx));
    }
    
    m_range_cache.Sort();
    
#ifdef LLDB_CONFIGURATION_DEBUG
    m_finalized = true;
#endif
}
コード例 #14
0
ファイル: Section.cpp プロジェクト: carlokok/lldb
SectionSP
SectionList::FindSectionContainingFileAddress (addr_t vm_addr, uint32_t depth) const
{
    SectionSP sect_sp;
    const_iterator sect_iter;
    const_iterator end = m_sections.end();
    for (sect_iter = m_sections.begin(); sect_iter != end && sect_sp.get() == NULL; ++sect_iter)
    {
        Section *sect = sect_iter->get();
        if (sect->ContainsFileAddress (vm_addr))
        {
            // The file address is in this section. We need to make sure one of our child
            // sections doesn't contain this address as well as obeying the depth limit
            // that was passed in.
            if (depth > 0)
                sect_sp = sect->GetChildren().FindSectionContainingFileAddress(vm_addr, depth - 1);

            if (sect_sp.get() == NULL && !sect->IsFake())
                sect_sp = *sect_iter;
        }
    }
    return sect_sp;
}
コード例 #15
0
ファイル: administrator.cpp プロジェクト: buguake/cms
// administrator removes a section
bool Administrator::RemoveSection(const Section &s) const
{
    /*delete a record from the section table*/

    QString str;
    str = "delete from Section where courseID = ";
    str += QString::number(s.GetCourseID());
    str += " and secID = ";
    str += QString::number(s.GetSecID());
    str += " and semester = '";
    str += s.GetSemester().data();
    str += "' and year = ";
    str += QString::number(s.GetYear());
    str += " and building = '";
    str += s.GetBuilding().data();
    str += "'";

    QSqlQuery query;
    if(!query.exec(str))
       return false;

    return true;
}
コード例 #16
0
std::vector<std::vector<Section*>> MysteryDungeonMaker::ClassifyGroups()
{
	std::vector<std::vector<Section*>> groups;
	int groupId = 0;

	int mapHeight=dungeonSize->DungeonRowNum();
	int sectionColumnNum = dungeonSize->DungeonColumnNum();
	for (int i = 0; i < mapHeight; i++)
	{
		for (int j = 0; j < sectionColumnNum; j++)
		{
			Section* current = &sections[i][j];
			if (current->HasRoom())
			{
				if (groups.empty())
				{
					groups.push_back(current->SetGroupId(groupId++));
				}
				else
				{
					int  notMarked = 0;
					for (size_t i_groups = 0; i_groups < groups.size(); i_groups++)
					{
						if (!DungeonMakerHelper::HasComponent(groups[i_groups], current->GetComponent()))
						{
							notMarked++;
						}
					}
					if (notMarked == groups.size())
						groups.push_back(current->SetGroupId(groupId++));
				}
			}
		}
	}

	return groups;
}
コード例 #17
0
Section*
XdfObject::AppendSection(llvm::StringRef name,
                         SourceLocation source,
                         Diagnostic& diags)
{
    bool code = (name == ".text");
    Section* section = new Section(name, code, false, source);
    m_object.AppendSection(std::auto_ptr<Section>(section));

    // Define a label for the start of the section
    Location start = {&section->bytecodes_front(), 0};
    SymbolRef sym = m_object.getSymbol(name);
    if (!sym->isDefined())
    {
        sym->DefineLabel(start);
        sym->setDefSource(source);
    }
    section->setSymbol(sym);

    // Add XDF data to the section
    section->AddAssocData(std::auto_ptr<XdfSection>(new XdfSection(sym)));

    return section;
}
コード例 #18
0
ファイル: BinaryWriter.cpp プロジェクト: AllanYiin/CNTK
bool BinaryWriter<ElemType>::SaveData(size_t recordStart, const std::map<std::wstring, void*, nocase_compare>& matrices, size_t numRecords, size_t datasetSize, size_t byteVariableSized)
{
    // allow restarting a writing session. This is used primarily for writing entire sections at once
    if (recordStart == 0)
    {
        m_recordCurrent = recordStart;
    }

    // make sure there are no gaps in the writing
    if (m_recordCurrent != recordStart)
    {
        RuntimeError("Caching with binary writer, records skip from %ld to %ld", m_recordCurrent, recordStart);
    }
    bool written = false;
    for (auto pair : m_sections)
    {
        Section* section = pair.second;
        written = section->SaveData(recordStart, matrices, numRecords, datasetSize, byteVariableSized) || written;
    }
    // the current record we expect to write next
    m_recordCurrent = recordStart + numRecords;

    return written;
}
コード例 #19
0
 void File::vLoad(const string& _rsFile,
     bool _bAddSection,
     bool _bAddKey)
 {
     string sBuffer = Glib::file_get_contents(_rsFile);
     Section* poSection = NULL;
     char** lines = g_strsplit(sBuffer.c_str(), "\n", 0);
     char* tmp;
     int i = 0;
     while (lines[i]) {
         if (lines[i][0] == '[') {
             if ((tmp = strchr(lines[i], ']'))) {
                 *tmp = '\0';
                 if (_bAddSection) {
                     poSection = poAddSection(&lines[i][1]);
                 } else {
                     try {
                         poSection = poGetSection(&lines[i][1]);
                     } catch (...) {
                         poSection = NULL;
                     }
                 }
             }
         } else if (lines[i][0] != '#' && poSection != NULL) {
             if ((tmp = strchr(lines[i], '='))) {
                 *tmp = '\0';
                 tmp++;
                 if (_bAddKey || poSection->bKeyExists(lines[i])) {
                     poSection->vSetKey(lines[i], tmp);
                 }
             }
         }
         i++;
     }
     g_strfreev(lines);
 }
コード例 #20
0
ファイル: EditMode.cpp プロジェクト: bairuiworld/MultiTracks
void TrackReviewMode::OnMapClick(ww::MouseEvent ev, const Location& location)
{
	if(ev.GetButton() != ww::MouseButton::Left || ev.GetClicks() != 1) return;
	WayPoint* wp = mWayPointSelector->GetCurrentWayPoint();
	if(!wp) return;
	if(!mLastWayPoint)
	{
		mLastWayPoint = new WayPoint(*wp);
		mMapRenderer->AddComponent(mLastWayPoint->GetLocation());
		return;
	}

	Section* subsection = mTrack->SubSection(mLastWayPoint, wp);
	subsection->SetParent(mTrack->GetReview());
	mTrack->GetReview()->Add(subsection);
	mSectionSelector->Add({subsection});
	mCurrentSectionSelector->Add({subsection});

	mMapRenderer->RemoveComponent(mLastWayPoint->GetLocation());
	delete mLastWayPoint;
	mLastWayPoint = nullptr;

	mMapRenderer->Invalidate();
}
コード例 #21
0
ファイル: raw.cpp プロジェクト: codenote/rp
std::vector<Section*> Raw::get_executables_section(std::ifstream & file)
{
    std::vector<Section*> executable_sections;

    unsigned long long raw_file_size = get_file_size(file);
    
    /* It is a raw file -> we have only one "virtual" section */
    Section *sect = new (std::nothrow) Section(
        ".raw",
        0,
        0,
        raw_file_size
    );

    if(sect == NULL)
        RAISE_EXCEPTION("Cannot allocate sect");
    
    sect->dump(file);
    sect->set_props(Section::Executable);

    executable_sections.push_back(sect);
    
    return executable_sections;
}
コード例 #22
0
void Schedule::CheckAdd(Section sect)
{
	vector<MinuteTimeRange> vmtr = sect.getMinuteTimeRange();
	for (auto minTimeRange : vmtr) {
		if (hashTable[minTimeRange.startTime] || hashTable[minTimeRange.endTime])
			return;
	}
	
	for (auto minTimeRange : vmtr) {
		for (int i = minTimeRange.startTime; i <= minTimeRange.endTime; ++i) {
			hashTable[i] = true;
		}
	}
	sections.push_back(sect);
}
コード例 #23
0
void
DynamicLoaderLinuxDYLD::UpdateLoadedSections(ModuleSP module, addr_t base_addr)
{
    ObjectFile *obj_file = module->GetObjectFile();
    SectionList *sections = obj_file->GetSectionList();
    SectionLoadList &load_list = m_process->GetTarget().GetSectionLoadList();
    const size_t num_sections = sections->GetSize();

    for (unsigned i = 0; i < num_sections; ++i)
    {
        Section *section = sections->GetSectionAtIndex(i).get();
        lldb::addr_t new_load_addr = section->GetFileAddress() + base_addr;
        lldb::addr_t old_load_addr = load_list.GetSectionLoadAddress(section);

        // If the file address of the section is zero then this is not an
        // allocatable/loadable section (property of ELF sh_addr).  Skip it.
        if (new_load_addr == base_addr)
            continue;

        if (old_load_addr == LLDB_INVALID_ADDRESS ||
            old_load_addr != new_load_addr)
            load_list.SetSectionLoadAddress(section, new_load_addr);
    }
}
コード例 #24
0
ファイル: administrator.cpp プロジェクト: buguake/cms
// administrator adds a section
bool Administrator::AddSection(const Section &s) const
{
    /*insert a record into the section table*/

    QSqlQuery query;
    query.prepare("insert into Section (courseID, secID, semester, year, capacity, vacancy, building, roomNo, timeSlotID) values (?, ?, ? ,?, ?, ?, ?, ?, ?)");
    query.addBindValue(s.GetCourseID());
    query.addBindValue(s.GetSecID());
    query.addBindValue(s.GetSemester().data());
    query.addBindValue(s.GetYear());
    query.addBindValue(s.GetCapacity());
    query.addBindValue(s.GetVacancy());
    query.addBindValue(s.GetBuilding().data());
    query.addBindValue(s.GetRoomNo());
    query.addBindValue(s.GetTimeSlotID());

    if(!query.exec())
        return false;

    return true;
}
コード例 #25
0
ファイル: ManagerImp.cpp プロジェクト: Joke-Dk/rippled
std::unique_ptr <Database>
ManagerImp::make_Database (
    std::string const& name,
    Scheduler& scheduler,
    beast::Journal journal,
    int readThreads,
    Section const& backendParameters,
    Section fastBackendParameters)
{
    std::unique_ptr <Backend> backend (make_Backend (
        backendParameters, scheduler, journal));

    std::unique_ptr <Backend> fastBackend (
        (fastBackendParameters.size () > 0)
            ? make_Backend (fastBackendParameters, scheduler, journal)
            : nullptr);

    return std::make_unique <DatabaseImp> (name, scheduler, readThreads,
        std::move (backend), std::move (fastBackend), journal);
}
コード例 #26
0
ファイル: profiler.cpp プロジェクト: MoLAoS/Mandate
void Section::print(ostream *outStream, int tabLevel){
	float percent = ( parent == NULL || parent->microsElapsed == 0 )
					? 100.0f : 100.0f * microsElapsed / parent->microsElapsed;
	string pname= parent==NULL? "": parent->getName();

	for(int i=0; i<tabLevel; ++i)
		*outStream << "\t";

	*outStream << name << ": ";

	if ( microsElapsed ) {
		*outStream << int(microsElapsed) << " us";
		unsigned int milliseconds = microsElapsed / 1000;
		unsigned int seconds = milliseconds / 1000;
		unsigned int minutes = seconds / 60;
		if ( minutes ) {
			*outStream << " (" << minutes << "min " << seconds % 60 << "sec)";
		}
		else if ( seconds ) {
			*outStream << " (" << seconds << "sec " << milliseconds % 1000 << "ms)";
		}
		else if ( milliseconds ) {
			*outStream << " (" << milliseconds << "ms)";
		}
		outStream->precision(1);
		*outStream << std::fixed << ", " << percent << "%";
	}
	if ( calls ) {
		*outStream << ", " << calls << " calls";
	}
	*outStream << "\n";

	SectionContainer::iterator it;
	for(it= children.begin(); it!=children.end(); ++it){
		it->second->print(outStream, tabLevel+1);
	}
}
コード例 #27
0
void
BinOutput::OutputSection(Section& sect, const IntNum& origin)
{
    BytecodeOutput* outputter;

    if (sect.isBSS())
    {
        outputter = &m_no_output;
    }
    else
    {
        IntNum file_start = sect.getLMA();
        file_start -= origin;
        if (file_start.getSign() < 0)
        {
            Diag(SourceLocation(), diag::err_section_before_origin)
                << sect.getName();
            return;
        }
        if (!file_start.isOkSize(sizeof(unsigned long)*8, 0, 0))
        {
            Diag(SourceLocation(), diag::err_start_too_large)
                << sect.getName();
            return;
        }
        m_fd_os.seek(file_start.getUInt());
        if (m_os.has_error())
        {
            Diag(SourceLocation(), diag::err_file_output_seek);
            return;
        }

        outputter = this;
    }

    for (Section::bc_iterator i=sect.bytecodes_begin(),
         end=sect.bytecodes_end(); i != end; ++i)
    {
        i->Output(*outputter);
    }
}
コード例 #28
0
MeiDocument* CScribeToNeoScribeXML::Scribe2MEIXML(const CScribeReaderVisitable& scribe_data)
{
    
    Mei* mei = new Mei;
    doc->setRootElement(mei);

    //create MEIhead to contain file, encoding, work and revision description
    MeiHead* mei_head = new MeiHead; //"meiHead"
    mei->addChild(mei_head);
    
    //Create and link fileDesc
    FileDesc* fileDesc = Scribe2MEIFileDesc();
    mei_head->addChild(fileDesc);
    
    //Create and link encodingDesc
    EncodingDesc* encodingDesc = Scribe2MEIEncoderDesc();
    mei_head->addChild(encodingDesc);
    
    //Create and link workDesc
    WorkDesc* workDesc = Scribe2MEIWorkDesc();
    mei_head->addChild(workDesc);
    //</meiHead> - not really at this stage - other elements completed in main routine
    
    //music - contains all music data
    Music* music = new Music;
    mei->addChild(music);
    Mdiv* mdiv = new Mdiv; //for chant source this needs to be specified repeatedly, with n and type attributes
    music->addChild(mdiv);
    Score* score = new Score;
    mdiv->addChild(score);
    
    //start adding score definitions - child of score
    ScoreDef* scoredef = new ScoreDef;
    score->addChild(scoredef);
    StaffGrp* staffgrp = new StaffGrp;
    scoredef->addChild(staffgrp);
    staffgrp->setId("all");
    
    int i=0;
    
    for (std::vector<scribe_part>::const_iterator partit = scribe_data.GetScribeParts().begin(); partit!=scribe_data.GetScribeParts().end(); partit++)
    {
        ++i;
        if (i==1)
        {
            Scribe2MEIXMLFileData(fileDesc, *partit);
            Scribe2MEIXMLWorkData(workDesc, *partit);
        }
        
        //add section - child of score
        Section* section = new Section();
        score->addChild(section);
        
        //handle staff and link to section
        Staff* staff = Scribe2MEIXMLStaff(scribe_data, *partit, staffgrp, i);
        section->addChild(staff);
        
    }
    
    return doc;
}
コード例 #29
0
void Configuration::parseUnions(INI& ini) {
	std::wstring unions =  ini.getString(L"main", L"union");
	std::list<std::wstring>::iterator it;
	std::list<std::wstring> unionsList;
	StringUtil::split(unionsList, unions, ',');

	if (unionsList.empty())
		throw UException(L"there is no unions");


	for (it = unionsList.begin() ; it != unionsList.end() ; it++) {
		std::wstring unionName = (*it);
		StringUtil::atrim(unionName);
		Union unionNode(unionName);

		std::wstring path = L"";
		std::wstring rsyncSrc = L"";
		std::wstring rsyncFilter = L"";
		bool deleteOnClose = false;
		std::wstring predefinedDirectory;

		Section* sec = ini.getSection(unionName);

		try {
			File path(sec->getString(L"path"));
			path.expand(this->srcPath);
			unionNode.setPath(path.path());

			try {
				File rsyncSrc(sec->getString(L"rsync"));
				rsyncSrc.expand(this->srcPath);
				unionNode.setRsyncSrc(rsyncSrc.path());

				rsyncFilter = sec->getString(L"rsync_filter");
				File f(rsyncFilter);
				f.expand();
				unionNode.setRsyncFilter(f.path());
			}
			catch (const UException&) { }

			try {
				deleteOnClose = sec->getBool(L"deleteOnEnd");
				unionNode.setDeleteOnClose(deleteOnClose);
			}
			catch (const UException&) { }

			try {
				bool translate = sec->getBool(L"translate");
				unionNode.setTranslate(translate);
			}
			catch (const UException&) { }

			try {
				std::list<std::wstring> l;
				std::list<std::wstring>::iterator it;
				std::wstring s = sec->getString(L"populate");
				StringUtil::unquote(s);
				StringUtil::split(l, s, L';');

				for( it = l.begin() ; it != l.end() ; it++) {
					std::wstring v = (*it);
					StringUtil::atrim(v);
					unionNode.addPredefinedDirectory(v);
				}
			}
			catch (const UException&) { }
		}
		catch (UException& e) {
			log_error(L"failed to parse union '%s': %s", (*it), e.wwhat());
			throw;
		}

		this->unions.push_front(unionNode);
	}
}
コード例 #30
0
void CScribeToNeoScribeXML::SegmentScribe2MEIXML(const CScribeReaderVisitable& scribe_data)
{
    std::unordered_set<std::string> rep_no_record;
    
    for (std::vector<scribe_part>::const_iterator part = scribe_data.GetScribeParts().begin(); part != scribe_data.GetScribeParts().end(); part++)
    {
        int i = 0;
        
        //save record of first part
        scribe_part first_part = *part;
        
        //create an instance of XML doc representation, etc.
        delete doc;
        doc = new MeiDocument();
        
        Mei *mei = new Mei;
        doc->setRootElement(mei);
        /*
            MEI
                - <meiHead>
                    - FileDescription
                    - EncodingDescription
                    - Work Description
                    - Revision Description
         
         */
        //create MEIhead to contain file, encoding, work and revision description
        MeiHead* mei_head = new MeiHead;
        mei->addChild(mei_head);
        
        AltId* altId = new AltId;
        mei_head->addChild(altId);
        if (scribe_data.GetType()==scribe_type::trecento)
        {
            altId->addAttribute("type", "repnum");
            altId->setValue(part->rep_num);
        } else if (scribe_data.GetType()==scribe_type::trecento)
        {
            altId->addAttribute("type", "cao");
            altId->setValue(std::to_string(part->cao_num));

        }
        //Create and link fileDesc
        FileDesc* fileDesc = Scribe2MEIFileDesc();
        mei_head->addChild(fileDesc);
        
        //Create and link encodingDesc
        EncodingDesc* encodingDesc = Scribe2MEIEncoderDesc();
        mei_head->addChild(encodingDesc);
        
        //Create and link workDesc
        WorkDesc* workDesc = Scribe2MEIWorkDesc();
        mei_head->addChild(workDesc);
        //</meiHead> - not really at this stage - other elements completed in main routine
        
        //music - contains all music data
        Music* music = new Music;
        mei->addChild(music);
        Mdiv* mdiv = new Mdiv; //for chant source this needs to be specified repeatedly, with n and type attributes
        music->addChild(mdiv);
        Score* score = new Score;
        mdiv->addChild(score);
        
        //start adding score definitions - child of score
        ScoreDef* scoredef = new ScoreDef;
        score->addChild(scoredef);
        StaffGrp* staffgrp = new StaffGrp;
        scoredef->addChild(staffgrp);
        staffgrp->setId("all");
        
        //skip along and collect parts - all have the same REPNUM
        
        std::string xml_file_name("");
        
        if (scribe_data.GetType()==scribe_type::trecento)
        {
            do
            {
                ++i;
                
                if (i==1)
                {
                    Scribe2MEIXMLFileData(fileDesc, *part);
                    Scribe2MEIXMLWorkData(workDesc, *part);
                }
                //add section - child of score
                Section* section = new Section;
                score->addChild(section);
                
                //handle staff and link to section
                Staff* staff = Scribe2MEIXMLStaff(scribe_data, *part, staffgrp, i);
                section->addChild(staff); //or TiXmlElement* layer;?
                
                part++;
                
            } while ( part->rep_num==first_part.rep_num && part != scribe_data.GetScribeParts().end());
            
            part--; // step back to last part in piece
            
            xml_file_name = first_part.rep_num;
            
            //find duplicates - doesn't find triplicates
            if (rep_no_record.find(part->rep_num) == rep_no_record.end())
            {
                rep_no_record.insert(part->rep_num);
            }
            else
            {
                xml_file_name += " copy";
            }
            
        }
        else if (scribe_data.GetType()==scribe_type::chant)
        {
            
            Scribe2MEIXMLFileData(fileDesc, *part);
            Scribe2MEIXMLWorkData(workDesc, *part);
            
                //add section - child of score
            Section* section = new Section;
            score->addChild(section);
                
                //handle staff and link to section
            Staff* staff = Scribe2MEIXMLStaff(scribe_data, *part, staffgrp, i);
            section->addChild(staff);
            
            xml_file_name = part->abbrev_ms + ZeroPadNumber(part->partID,4)+ " (" + std::to_string(first_part.cao_num) + ")";
            
        }
        
        //need to check if there already exists a file with the same name
        
        xml_file_name +=  ".xml";
        
        SaveMEIXML(xml_file_name);
    
    }
    
}