本文整理汇总了C++中KeyList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyList::begin方法的具体用法?C++ KeyList::begin怎么用?C++ KeyList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyList
的用法示例。
在下文中一共展示了KeyList::begin方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateSection
// Given a section name, this function first checks to see if the given section
// allready exists in the list or not, if not, it creates the new section and
// assigns it the comment given in mComment. The function returns true if
// sucessfully created, or false otherwise. This version accpets a KeyList
// and Writes up the newly created Section with the keys in the list.
bool IniFile::CreateSection(const string& Section, const string& Comment, KeyList Keys)
{
if ( !CreateSection(Section, Comment) )
return false;
IniSection* pSection = GetSection(Section);
if ( !pSection )
return false;
KeyItor k_pos;
pSection->mName = Section;
for (k_pos = Keys.begin(); k_pos != Keys.end(); k_pos++)
{
IniKey* pKey = new IniKey;
pKey->mComment = (*k_pos)->mComment;
pKey->mKey = (*k_pos)->mKey;
pKey->mValue = (*k_pos)->mValue;
pSection->mKeys.push_back(pKey);
}
mSections.push_back(pSection);
mIsDirty = true;
return true;
}
示例2: CreateSection
// CreateSection
// Given a section name, this function first checks to see if the given section
// allready exists in the list or not, if not, it creates the new section and
// assigns it the comment given in szComment. The function returns true if
// sucessfully created, or false otherwise. This version accpets a KeyList
// and sets up the newly created Section with the keys in the list.
bool CDataFile::CreateSection(t_Str szSection, t_Str szComment, KeyList Keys)
{
if ( !CreateSection(szSection, szComment) )
return false;
t_Section* pSection = GetSection(szSection);
if ( !pSection )
return false;
KeyItor k_pos;
pSection->szName = szSection;
for (k_pos = Keys.begin(); k_pos != Keys.end(); k_pos++)
{
t_Key key;
key.szComment = (*k_pos).szComment;
key.szKey = (*k_pos).szKey;
key.szValue = (*k_pos).szValue;
pSection->Keys.push_back(key);
}
m_Sections.push_back(*pSection);
m_bDirty = true;
return true;
}
示例3: RemoveNotificationKeys
//
// returns number of keys left after removal
//
int plStateChangeNotifier::RemoveNotificationKeys(KeyList keys)
{
KeyList::iterator it=keys.begin();
for( ; it != keys.end(); it++)
IRemoveKey(*it);
return fKeys.size();
}
示例4: insertTime
void KeyList::insertTime(int tick, int len)
{
KeyList tmp;
for (ciKeyList i = begin(); i != end(); ++i) {
if ((i->first >= tick) && (tick != 0))
tmp[i->first + len] = i->second;
else
tmp[i->first] = i->second;
}
clear();
insert(tmp.begin(), tmp.end());
}
示例5: getSlerpValue
Quat getSlerpValue( const KeyList &keys,float time )const{
KeyList::const_iterator next,curr;
//for( next=keys.begin();next!=keys.end() && time>=next->first;++next ){}
next=keys.upper_bound( (int)time );
if( next==keys.begin() ) return next->second;
curr=next;--curr;
if( next==keys.end() ) return curr->second;
float delta=( time-curr->first )/( next->first-curr->first );
return curr->second.slerpTo( next->second,delta );
}
示例6: getLinearValue
Vector getLinearValue( const KeyList &keys,float time )const{
KeyList::const_iterator next,curr;
//for( next=keys.begin();next!=keys.end() && time>=next->first;++next ){}
next=keys.upper_bound( (int)time );
if( next==keys.begin() ) return next->second.v;
curr=next;--curr;
if( next==keys.end() ) return curr->second.v;
float delta=( time-curr->first )/( next->first-curr->first );
return ( next->second.v-curr->second.v )*delta+curr->second.v;
}
示例7: removeTime
void KeyList::removeTime(int tick, int len)
{
KeyList tmp;
for (ciKeyList i = begin(); i != end(); ++i) {
if ((i->first >= tick) && (tick != 0)) {
if (i->first >= tick + len)
tmp[i->first - len] = i->second;
else
printf("remove key event\n");
}
else
tmp[i->first] = i->second;
}
clear();
insert(tmp.begin(), tmp.end());
}
示例8: assignKeyListToStaff
void assignKeyListToStaff(const KeyList &kl, Staff *staff)
{
Score* score = staff->score();
const int track = staff->idx() * VOICES;
Key pkey = Key::C;
for (auto it = kl.begin(); it != kl.end(); ++it) {
const int tick = it->first;
Key key = it->second.key();
if ((key == Key::C) && (key == pkey)) // dont insert uneccessary C key
continue;
pkey = key;
KeySig* ks = new KeySig(score);
ks->setTrack(track);
ks->setGenerated(false);
ks->setKey(key);
ks->setMag(staff->mag());
Measure* m = score->tick2measure(tick);
Segment* seg = m->getSegment(ks, tick);
seg->add(ks);
}
}
示例9: if
int
TransportRegistry::load_transport_configuration(const OPENDDS_STRING& file_name,
ACE_Configuration_Heap& cf)
{
const ACE_Configuration_Section_Key &root = cf.root_section();
// Create a vector to hold configuration information so we can populate
// them after the transports instances are created.
typedef std::pair<TransportConfig_rch, OPENDDS_VECTOR(OPENDDS_STRING) > ConfigInfo;
OPENDDS_VECTOR(ConfigInfo) configInfoVec;
// Record the transport instances created, so we can place them
// in the implicit transport configuration for this file.
OPENDDS_LIST(TransportInst_rch) instances;
ACE_TString sect_name;
for (int index = 0;
cf.enumerate_sections(root, index, sect_name) == 0;
++index) {
if (ACE_OS::strcmp(sect_name.c_str(), TRANSPORT_SECTION_NAME) == 0) {
// found the [transport/*] section, now iterate through subsections...
ACE_Configuration_Section_Key sect;
if (cf.open_section(root, sect_name.c_str(), 0, sect) != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("failed to open section %s\n"),
sect_name.c_str()),
-1);
} else {
// Ensure there are no properties in this section
ValueMap vm;
if (pullValues(cf, sect, vm) > 0) {
// There are values inside [transport]
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("transport sections must have a section name\n"),
sect_name.c_str()),
-1);
}
// Process the subsections of this section (the individual transport
// impls).
KeyList keys;
if (processSections( cf, sect, keys ) != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("too many nesting layers in [%s] section.\n"),
sect_name.c_str()),
-1);
}
for (KeyList::const_iterator it=keys.begin(); it != keys.end(); ++it) {
OPENDDS_STRING transport_id = (*it).first;
ACE_Configuration_Section_Key inst_sect = (*it).second;
ValueMap values;
if (pullValues( cf, (*it).second, values ) != 0) {
// Get the factory_id for the transport.
OPENDDS_STRING transport_type;
ValueMap::const_iterator vm_it = values.find("transport_type");
if (vm_it != values.end()) {
transport_type = (*vm_it).second;
} else {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("missing transport_type in [transport/%C] section.\n"),
transport_id.c_str()),
-1);
}
// Create the TransportInst object and load the transport
// configuration in ACE_Configuration_Heap to the TransportInst
// object.
TransportInst_rch inst = this->create_inst(transport_id,
transport_type);
if (inst == 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("Unable to create transport instance in [transport/%C] section.\n"),
transport_id.c_str()),
-1);
}
instances.push_back(inst);
inst->load(cf, inst_sect);
} else {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("missing transport_type in [transport/%C] section.\n"),
transport_id.c_str()),
-1);
}
}
}
} else if (ACE_OS::strcmp(sect_name.c_str(), CONFIG_SECTION_NAME) == 0) {
// found the [config/*] section, now iterate through subsections...
ACE_Configuration_Section_Key sect;
if (cf.open_section(root, sect_name.c_str(), 0, sect) != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
ACE_TEXT("failed to open section [%s]\n"),
sect_name.c_str()),
-1);
//.........这里部分代码省略.........
示例10: if
//.........这里部分代码省略.........
for (int idx = 0; idx < n; ++idx) {
Staff* s = _staves[idx];
int track = idx * VOICES;
// check barLineSpan
if (s->barLineSpan() > (n - idx)) {
qDebug("read114: invalid bar line span %d (max %d)",
s->barLineSpan(), n - idx);
s->setBarLineSpan(n - idx);
}
for (auto i : e.clefs(idx)) {
int tick = i.first;
ClefType clefId = i.second;
Measure* m = tick2measure(tick);
if (!m)
continue;
if ((tick == m->tick()) && m->prevMeasure())
m = m->prevMeasure();
Segment* seg = m->getSegment(Segment::Type::Clef, tick);
if (seg->element(track))
static_cast<Clef*>(seg->element(track))->setGenerated(false);
else {
Clef* clef = new Clef(this);
clef->setClefType(clefId);
clef->setTrack(track);
clef->setParent(seg);
clef->setGenerated(false);
seg->add(clef);
}
}
// create missing KeySig
KeyList* km = s->keyList();
for (auto i = km->begin(); i != km->end(); ++i) {
int tick = i->first;
if (tick < 0) {
qDebug("read114: Key tick %d", tick);
continue;
}
if (tick == 0 && i->second.key() == Key::C)
continue;
Measure* m = tick2measure(tick);
if (!m) //empty score
break;
Segment* seg = m->getSegment(Segment::Type::KeySig, tick);
if (seg->element(track))
static_cast<KeySig*>(seg->element(track))->setGenerated(false);
else {
KeySigEvent ke = i->second;
KeySig* ks = new KeySig(this);
ks->setKeySigEvent(ke);
ks->setParent(seg);
ks->setTrack(track);
ks->setGenerated(false);
seg->add(ks);
}
}
}
for (std::pair<int,Spanner*> p : spanner()) {
Spanner* s = p.second;
if (s->type() != Element::Type::SLUR) {
if (s->type() == Element::Type::VOLTA) {
Volta* volta = static_cast<Volta*>(s);
volta->setAnchor(Spanner::Anchor::MEASURE);
}
示例11: AddNotificationKeys
void plStateChangeNotifier::AddNotificationKeys(KeyList keys)
{
KeyList::iterator it=keys.begin();
for( ; it != keys.end(); it++)
IAddKey(*it);
}
示例12: convertTrack
void MTrack::convertTrack(const Fraction &lastTick)
{
Score* score = staff->score();
int key = 0; // TODO-LIB findKey(mtrack, score->sigmap());
int track = staff->idx() * VOICES;
int voices = VOICES;
for (int voice = 0; voice < voices; ++voice) {
// startChordTick is onTime value of all simultaneous notes
// chords here are consist of notes with equal durations
// several chords may have the same onTime value
Fraction startChordTick;
QList<MidiChord> midiChords;
for (auto it = chords.begin(); it != chords.end();) {
const Fraction &nextChordTick = it->first;
const MidiChord& midiChord = it->second;
if (midiChord.voice != voice) {
++it;
continue;
}
processPendingNotes(midiChords, voice, startChordTick, nextChordTick);
// now 'midiChords' list is empty
// so - fill it:
// collect all midiChords on current tick position
startChordTick = nextChordTick; // debug
for (;it != chords.end(); ++it) {
const MidiChord& midiChord = it->second;
if (it->first != startChordTick)
break;
if (midiChord.voice != voice)
continue;
midiChords.append(midiChord);
}
if (midiChords.isEmpty())
break;
}
// process last chords at the end of the score
processPendingNotes(midiChords, voice, startChordTick, lastTick);
}
createTuplets(track, score);
KeyList* km = staff->keymap();
if (!hasKey && !mtrack->drumTrack()) {
KeySigEvent ks;
ks.setAccidentalType(key);
(*km)[0] = ks;
}
for (auto it = km->begin(); it != km->end(); ++it) {
int tick = it->first;
KeySigEvent key = it->second;
KeySig* ks = new KeySig(score);
ks->setTrack(track);
ks->setGenerated(false);
ks->setKeySigEvent(key);
ks->setMag(staff->mag());
Measure* m = score->tick2measure(tick);
Segment* seg = m->getSegment(ks, tick);
seg->add(ks);
}
#if 0 // TODO
ClefList* cl = staff->clefList();
for (ciClefEvent i = cl->begin(); i != cl->end(); ++i) {
int tick = i.key();
Clef* clef = new Clef(score);
clef->setClefType(i.value());
clef->setTrack(track);
clef->setGenerated(false);
clef->setMag(staff->mag());
Measure* m = score->tick2measure(tick);
Segment* seg = m->getSegment(clef, tick);
seg->add(clef);
}
#endif
}
示例13: editInstrList
void MuseScore::editInstrList()
{
if (cs == 0)
return;
if (!instrList)
instrList = new InstrumentsDialog(this);
else if (instrList->isVisible()) {
instrList->done(0);
return;
}
instrList->init();
MasterScore* masterScore = cs->masterScore();
instrList->genPartList(masterScore);
masterScore->startCmd();
masterScore->deselectAll();
int rv = instrList->exec();
if (rv == 0) {
masterScore->endCmd();
return;
}
ScoreView* csv = currentScoreView();
if (csv && csv->noteEntryMode()) {
csv->cmd(getAction("escape"));
qApp->processEvents();
updateInputState(csv->score());
}
masterScore->inputState().setTrack(-1);
// keep the keylist of the first pitched staff to apply it to new ones
KeyList tmpKeymap;
Staff* firstStaff = 0;
for (Staff* s : masterScore->staves()) {
KeyList* km = s->keyList();
if (!s->isDrumStaff(Fraction(0,1))) { // TODO
tmpKeymap.insert(km->begin(), km->end());
firstStaff = s;
break;
}
}
Key normalizedC = Key::C;
// normalize the keyevents to concert pitch if necessary
if (firstStaff && !masterScore->styleB(Sid::concertPitch) && firstStaff->part()->instrument()->transpose().chromatic ) {
int interval = firstStaff->part()->instrument()->transpose().chromatic;
normalizedC = transposeKey(normalizedC, interval);
for (auto i = tmpKeymap.begin(); i != tmpKeymap.end(); ++i) {
int tick = i->first;
Key oKey = i->second.key();
tmpKeymap[tick].setKey(transposeKey(oKey, interval));
}
}
// create initial keyevent for transposing instrument if necessary
auto i = tmpKeymap.begin();
if (i == tmpKeymap.end() || i->first != 0)
tmpKeymap[0].setKey(normalizedC);
//
// process modified partitur list
//
QTreeWidget* pl = instrList->partiturList();
Part* part = 0;
int staffIdx = 0;
QTreeWidgetItem* item = 0;
for (int idx = 0; (item = pl->topLevelItem(idx)); ++idx) {
PartListItem* pli = static_cast<PartListItem*>(item);
// check if the part contains any remaining staves
// mark to remove part if not
QTreeWidgetItem* ci = 0;
int staves = 0;
for (int cidx = 0; (ci = pli->child(cidx)); ++cidx) {
StaffListItem* sli = static_cast<StaffListItem*>(ci);
if (sli->op() != ListItemOp::I_DELETE)
++staves;
}
if (staves == 0)
pli->op = ListItemOp::I_DELETE;
}
item = 0;
for (int idx = 0; (item = pl->topLevelItem(idx)); ++idx) {
int rstaff = 0;
PartListItem* pli = static_cast<PartListItem*>(item);
if (pli->op == ListItemOp::I_DELETE)
masterScore->cmdRemovePart(pli->part);
else if (pli->op == ListItemOp::ADD) {
const InstrumentTemplate* t = ((PartListItem*)item)->it;
part = new Part(masterScore);
part->initFromInstrTemplate(t);
masterScore->undo(new InsertPart(part, staffIdx));
pli->part = part;
QList<Staff*> linked;
for (int cidx = 0; pli->child(cidx); ++cidx) {
StaffListItem* sli = static_cast<StaffListItem*>(pli->child(cidx));
Staff* staff = new Staff(masterScore);
staff->setPart(part);
sli->setStaff(staff);
staff->init(t, sli->staffType(), cidx);
//.........这里部分代码省略.........
示例14: InfoRepoDiscovery
int
InfoRepoDiscovery::Config::discovery_config(ACE_Configuration_Heap& cf)
{
const ACE_Configuration_Section_Key& root = cf.root_section();
ACE_Configuration_Section_Key repo_sect;
if (cf.open_section(root, REPO_SECTION_NAME, 0, repo_sect) != 0) {
if (DCPS_debug_level > 0) {
// This is not an error if the configuration file does not have
// any repository (sub)section. The code default configuration will be used.
ACE_DEBUG((LM_NOTICE,
ACE_TEXT("(%P|%t) NOTICE: InfoRepoDiscovery::Config::discovery_config ")
ACE_TEXT("failed to open [%s] section.\n"),
REPO_SECTION_NAME));
}
return 0;
} else {
// Ensure there are no properties in this section
ValueMap vm;
if (pullValues(cf, repo_sect, vm) > 0) {
// There are values inside [repo]
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
ACE_TEXT("repo sections must have a subsection name\n")),
-1);
}
// Process the subsections of this section (the individual repos)
KeyList keys;
if (processSections( cf, repo_sect, keys ) != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
ACE_TEXT("too many nesting layers in the [repo] section.\n")),
-1);
}
// Loop through the [repo/*] sections
for (KeyList::const_iterator it=keys.begin(); it != keys.end(); ++it) {
std::string repo_name = (*it).first;
ValueMap values;
pullValues( cf, (*it).second, values );
Discovery::RepoKey repoKey = Discovery::DEFAULT_REPO;
bool repoKeySpecified = false, bitIpSpecified = false,
bitPortSpecified = false;
std::string repoIor;
int bitPort = 0;
std::string bitIp;
for (ValueMap::const_iterator it=values.begin(); it != values.end(); ++it) {
std::string name = (*it).first;
if (name == "RepositoryKey") {
repoKey = (*it).second;
repoKeySpecified = true;
if (DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) [repository/%C]: RepositoryKey == %C\n"),
repo_name.c_str(), repoKey.c_str()));
}
} else if (name == "RepositoryIor") {
repoIor = (*it).second;
if (DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) [repository/%C]: RepositoryIor == %C\n"),
repo_name.c_str(), repoIor.c_str()));
}
} else if (name == "DCPSBitTransportIPAddress") {
bitIp = (*it).second;
bitIpSpecified = true;
if (DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) [repository/%C]: DCPSBitTransportIPAddress == %C\n"),
repo_name.c_str(), bitIp.c_str()));
}
} else if (name == "DCPSBitTransportPort") {
std::string value = (*it).second;
bitPort = ACE_OS::atoi(value.c_str());
bitPortSpecified = true;
if (convertToInteger(value, bitPort)) {
} else {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
ACE_TEXT("Illegal integer value for DCPSBitTransportPort (%C) in [repository/%C] section.\n"),
value.c_str(), repo_name.c_str()),
-1);
}
if (DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) [repository/%C]: DCPSBitTransportPort == %d\n"),
repo_name.c_str(), bitPort));
}
} else {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) InfoRepoDiscovery::Config::discovery_config ")
ACE_TEXT("Unexpected entry (%C) in [repository/%C] section.\n"),
name.c_str(), repo_name.c_str()),
-1);
}
//.........这里部分代码省略.........