Пример #1
0
//ctrl-alt-del
//control-PgUp
//control-Num Lock
void CGraphmatFile::DealModifierKey(size_t LB, size_t  HB)
{
  size_t SaveStart = LB;
  if (LB+3 > HB) return ;
  if (!HasDescr (LB+1, OHyp)) return ;

  // ищем в модификаторах
  if (!GetUnits()[LB].IsKeyModifier()) return;
  LB += 2;
  if  (    (LB+3 <= HB)
	    && HasDescr (LB+1, OHyp)
		&& GetUnits()[LB].IsKeyModifier()
	  )
    LB+=2;


  // ищем в клавишах
  size_t GraLast;
  if (!IsKey(LB, HB, GraLast)) return;

  if (!HasGrouped(SaveStart,GraLast) )
  {
     SetDes (SaveStart, OKey1);
     SetDes (GraLast-1, OKey2);
     SetState(SaveStart,GraLast,stGrouped);

  }
    
};
Пример #2
0
 int NumRequests(const FactoryBase* factory, const std::string & ename) const {
   TEUCHOS_TEST_FOR_EXCEPTION(!IsKey(factory, ename), Exceptions::RuntimeError, "\"" + ename + "\" not found. Do a request first.");
   const Teuchos::RCP<MueLu::VariableContainer>& v = Get(factory, ename);
   TEUCHOS_TEST_FOR_EXCEPTION(v->NumAllRequests() == 0 && v->GetKeepFlag() == 0, Exceptions::RuntimeError,
                              "NumRequests(): Internal logic error: if counter == 0, the entry in countTable_ should have been deleted");
   return v->NumAllRequests();
 }
Пример #3
0
sint64 VDAVIReadIndex::NextKey(sint64 samplePos) const {
	if (samplePos < 0) {
		if (IsKey(0))
			return true;
		samplePos = 0;
	}

	if (samplePos >= mSampleCount)
		return -1;

	uint32 sectorIndex = FindSectorIndexBySample(samplePos);
	uint32 sampleOffset;
	uint32 chunkIndex;
	IndexEntry *ient = FindChunk(samplePos, sectorIndex, sampleOffset, chunkIndex);

	while(++chunkIndex < mChunkCount) {
		ient = &mIndex[chunkIndex >> kBlockSizeBits][chunkIndex & kBlockMask];
		if ((sint32)ient->mSizeAndKeyFrameFlag < 0) {
			sectorIndex = FindSectorIndexByChunk(chunkIndex);

			return mSectors[sectorIndex].mChunkOffset + ient->mSampleOffset;
		}
	}

	return -1;
}
Пример #4
0
void CSchemaItem::WriteArchive( IArchive *ar )
{
	ar->StartClass( _T("edit") );
	ar->Write( m_hszType.GetString(), _T("type") );
	ar->Write( m_hszLabel.GetString(), _T("name") );
	ar->Write( IsKey(), _T("key") );
	ar->EndClass();
}
Пример #5
0
 //! Test whether a need has been requested.  Note: this tells nothing about whether the need's value exists.
 bool IsRequested(const std::string& ename, const FactoryBase* factory = NoFactory::get()) const {
   if (!IsKey(factory, ename))
     return false;
   try {
     return IsRequested(Get(factory, ename));
   } catch (...) {
     return false;
   }
 }
Пример #6
0
 //! Test whether a need's value has been saved.
 bool IsAvailable(const std::string& ename, const FactoryBase* factory = NoFactory::get()) const {
   if (!IsKey(factory, ename))
     return false;
   try {
     return Get(factory, ename)->IsAvailable();
   } catch (...) {
     return false;
   }
 }
Пример #7
0
////////////////////////////////////////////////////////////////////////
// 描    述:  读取指定的配置项的整型值,并允许指定未配置时的缺省值
// 作    者:  邵凯田
// 创建时间:  2011-11-13 16:14
// 参数说明:  @sGroup表示组名称(中括号的标题)
//            @sField表示组内的配置项名称
//            @idefault表示读取失败(未配置的情况下)时的缺省值
// 返 回 值:  配置值
//////////////////////////////////////////////////////////////////////////
int SIniFile::GetKeyIntValue(SString sGroup, SString sField, int idefault /*= 0*/)
{
	if(!IsKey(sGroup,sField))
		return idefault;

	SString val=GetValue(sGroup,sField);
	if(val.size() == 0)
		return idefault;

	return atoi(val.data());
}
Пример #8
0
    //! Delete data that have been retained after the setup phase (using Keep(), AddKeepFlag(), or internal MueLu logic).
    // Special cases:
    // - If entry (ename, factory) does not exist, nothing is done.
    // - If entry exists but counter !=, entry cannot be desallocated before counter set to 0 (using Release()) so an exeption is thrown.
    void Delete(const std::string& ename, const FactoryBase* factory) { // Note: do not add default value for input parameter 'factory'
      if (!IsKey(ename, factory)) { return; } // if entry (ename, factory) does not exist, nothing is done.

      // Precondition:
      // Delete() should only be called if counter == 0
      // Note: It better to throw an exception rather than deleting the data if counter != 0 because users are not supposed to manipulate data with counter != 0
      TEUCHOS_TEST_FOR_EXCEPTION(IsRequested(ename, factory) == true, Exceptions::RuntimeError, "MueLu::Level::Delete(): IsRequested() == true. Ref counter != 0. You are not allowed to delete data that are still in use.");
      // If counter == 0 and entry exists, this means that a keep flag is set. Or there is an internal logic problem.
      TEUCHOS_TEST_FOR_EXCEPTION(GetKeepFlag(ename, factory) == 0, Exceptions::RuntimeError, "MueLu::Level::Delete(), Keep flag == 0?");

      RemoveKeepFlag(ename, factory, MueLu::All); // will delete the data if counter == 0

      // Post condition: data must have been deleted
      TEUCHOS_TEST_FOR_EXCEPTION(IsAvailable(ename, factory) == true, Exceptions::RuntimeError, "MueLu::Level::Delete(): Internal error (Post condition). Data have not been deleted.");
    }
Пример #9
0
void CSWCommandLine::Parse (CUniversalText utCmdLine)
{
	Cleanup ();
	static CUniversalText utDelimiters = L" \t\r\n";
	
	UINT uBeg = 0, uEnd = 0, uLen; 
	bool fQuoteOpened = false, fTrimmed = false;

	while (uEnd <= (uLen = utCmdLine.GetLength ()))
	{
		if (uEnd == uLen || (utDelimiters.FindWCHAR (utCmdLine.GetWCHAR (uEnd)) != -1 && !fQuoteOpened))
		{
			if (fTrimmed)
			{
				CUniversalText* pNewWord;
				pNewWord = new CUniversalText (utCmdLine.Mid (uBeg, uEnd - uBeg));

				m_rgputAll.Add (pNewWord);
				if (IsKey (*pNewWord))
					m_rgputKeys.Add ((pNewWord));
				else
					m_rgputFormal.Add (pNewWord);
			}
			fTrimmed = false;
			uBeg = uEnd;
		}
		else
		{
			if (utCmdLine.GetWCHAR (uEnd) == L'"')
			{
				fQuoteOpened = !fQuoteOpened;
				utCmdLine.Delete (1, uEnd);
				continue;
			}
			else
			{
				if (!fTrimmed)
				{
					uBeg = uEnd;
					fTrimmed = true;
				}
			}
		}
		uEnd++;
	}
}
Пример #10
0
void RegTreeCtrl::TreeNode::Refresh()
{
    if ( !IsKey() )
        return;

    wxTreeItemId theId(Id()); // Temp variable seems necessary for BC++
    bool wasExpanded = m_pTree->IsExpanded(theId);
    if ( wasExpanded )
        m_pTree->Collapse(theId);

    OnCollapse();
    m_pTree->SetItemHasChildren(theId);
    if ( wasExpanded )
    {
        m_pTree->Expand(theId);
        OnExpand();
    }
}
Пример #11
0
    void Set(const std::string& ename, const T& entry, const FactoryBase* factory = NoFactory::get()) {
      const FactoryBase* fac = GetFactory(ename, factory);

      if (fac == NoFactory::get()) {
        // Any data set with a NoFactory gets UserData keep flag by default
        AddKeepFlag(ename, NoFactory::get(), MueLu::UserData);
      }

      // Store entry only if data have been requested (or any keep flag)
      if (IsRequested(ename, factory) || GetKeepFlag(ename, factory) != 0) {
        TEUCHOS_TEST_FOR_EXCEPTION(!IsKey(factory, ename), Exceptions::RuntimeError, "" + ename + " not found in");
        map_[factory][ename]->SetData(entry);

      } else {
        GetOStream(Warnings0) << "Level::Set: unable to store \"" << ename << "\" generated by factory " << factory
            << " on level " << toString(GetLevelID()) << ", as it has not been requested and no keep flags were set for it" << std::endl;
      }
    } // Set
Пример #12
0
// F1-z
void CGraphmatFile::DealSimpleKey(size_t LB, size_t  HB)
{
	// ищем в клавишах
  size_t GraLast;
  if (    !IsKey(LB, HB, GraLast)
	 ) return;

  if (    (LB+1 == GraLast)
	   && IsOneAlpha(LB)
	 )
	 return;

  if (!HasGrouped(LB, GraLast) )
  {
     SetDes (LB, OKey1);
     SetDes (GraLast-1, OKey2);
     SetState(LB,GraLast,stGrouped);
  }
};
Пример #13
0
bool CScript::FindKey( LPCTSTR pszName ) // Find a key in the current section
{
	ADDTOCALLSTACK("CScript::FindKey");
	if ( strlen( pszName ) > SCRIPT_MAX_SECTION_LEN )
	{
		DEBUG_ERR(( "Bad script key name\n" ));
		return( false );
	}
	Seek( m_lSectionData );
	while ( ReadKeyParse())
	{
		if ( IsKey( pszName ))
		{
			m_pszArg = Str_TrimWhitespace( m_pszArg );
			return true;
		}
	}
	return( false );
}
Пример #14
0
    T& Get(const std::string& ename, const FactoryBase* factory = NoFactory::get()) {
      const FactoryBase* fac = GetFactory(ename, factory);
      // printf("(l=%d)                                               getting    \"%20s\" generated by %10p  [actually, generated by %p (%43s)]\n",
             // levelID_, ename.c_str(), factory, fac, fac->description().c_str());

      TEUCHOS_TEST_FOR_EXCEPTION(!IsKey(fac, ename), Exceptions::RuntimeError, "\"" + ename + "\" not found");

      if (!IsAvailable(ename, fac)) {
        TEUCHOS_TEST_FOR_EXCEPTION(NumRequests(fac, ename) < 1 && GetKeepFlag(ename, fac) == 0, Exceptions::RuntimeError,
                                   "\"" << ename << "\" has not been requested (counter = " << NumRequests(fac, ename) << ", "
                                   "KeepFlag = " << GetKeepFlag(ename, fac) << "). " << std::endl <<
                                   "Generating factory:" << *fac << " NoFactory = " << NoFactory::get());
        fac->CallBuild(*this);
        Release(*fac);
      }

      TEUCHOS_TEST_FOR_EXCEPTION(!IsAvailable(ename, fac), Exceptions::RuntimeError, "MueLu::Level::Get(): factory did not produce expected output. "
                                 "\"" << ename << "\" has not been generated by " << *fac);

      return map_[fac][ename]->template GetData<T>();
    }
Пример #15
0
                void Sep_Val()
                {
                    Opri=0;                 
		    invToki=0;
		    Ideni=0;
		    Coni=0;
		    Keyi=0;
		    for(i=0;i<uqIdi;i++)
		    {
			if(IsIden(uqIden[i][0]))
			{
			    if(IsKey(uqIden[i]))
			    {
				strcpy(Key[Keyi++],uqIden[i]);
			    }
			    else
			    {
				ptfl=1;
				for(j=0;j<strlen(uqIden[i])&&ptfl;j++)
				{
					if(uqIden[i][j]=='.')
					{
						strcpy(invalTok[invToki++],uqIden[i]);
						ptfl=0;
					}
				}
				if(ptfl)
				{
					strcpy(Iden[Ideni++],uqIden[i]);
				}
			    }
			}
			else
			{
			    tfl=1;
			    ptfl=0;
			    for(j=0;j<strlen(uqIden[i])&&tfl;j++)
			    {
				if(IsIden(uqIden[i][j]))
				{
				    strcpy(invalTok[invToki++],uqIden[i]);
				    tfl=0;
				}
				else if(uqIden[i][j]=='.')
				{
					if(ptfl)
					{
						strcpy(invalTok[invToki++],uqIden[i]);
						tfl=0;
					}
					if(!ptfl)
					{
						ptfl=1;
					}
				}
			    }
			    if(tfl)
			    {
				strcpy(Con[Coni++],uqIden[i]);
			    }
			}
                    }
                    for(i=0;i<uqOpi;i++)
                    {
                        tfl=1;
                        for(j=0;j<defOpi&&tfl;j++)
                        {
                            if(!strcmp(uqOpr[i],defOprStr[j]))
                            {   
                                strcpy(Opr[Opri++],uqOpr[i]);
                                tfl=0;
                            }
                        }
                        if(tfl)
                        {
                            strcpy(invalTok[invToki++],uqOpr[i]);
                        }
                    }
                }
Пример #16
0
 bool IsUserInput() const {
   return IsKey() || IsMouse();
 }
Пример #17
0
  unsigned GetKeyCode() const {
    assert(IsKey());

    return event.key.keysym.sym;
  }
Пример #18
0
char *printallmodes(channel *cp) {
  static char buf[1024];
  char buf2[12];

  if(IsLimit(cp))
    snprintf(buf2, sizeof(buf2), "%d", cp->limit);

  snprintf(buf, sizeof(buf), "%s %s%s%s", printflags(cp->flags, cmodeflags), IsLimit(cp)?buf2:"", IsLimit(cp)?" ":"", IsKey(cp)?cp->key->content:"");

  return buf;
}
Пример #19
0
////////////////////////////////////////////////////////////////////////
// 描    述:  读取指定的配置项的字符串值,并允许指定未配置时的缺省值
// 作    者:  邵凯田
// 创建时间:  2011-11-13 16:20
// 参数说明:  @sGroup表示组名称(中括号的标题)
//            @sField表示组内的配置项名称
//            @szdefault表示读取失败(未配置的情况下)时的缺省值
// 返 回 值:  配置值
//////////////////////////////////////////////////////////////////////////
SString SIniFile::GetKeyStringValue(SString sGroup, SString sField, SString szdefault /*= ""*/)
{
	if(!IsKey(sGroup,sField))
		return szdefault;
	return GetValue(sGroup,sField);
}
Пример #20
0
 bool IsUserInput() const {
   return IsKey() || (GetCharacterCount() > 0) || IsMouse();
 }
Пример #21
0
  unsigned GetKeyCode() const {
    assert(IsKey());

    return msg.wParam;
  }
Пример #22
0
int handleburstmsg(void *source, int cargc, char **cargv) {
  channel *cp;
  time_t timestamp;
  int wipeout=0;
  int i;
  int arg=0;
  char *charp;
  int newlimit;
  int waslimit,waskeyed;
  char *nextnum;
  unsigned long currentmode;
  int isnewchan;
  
  /* (we don't see the first 2 params in cargc) */
  /* AK B #+lod+ 1017561154 +tnk eits ATJWu:o,AiW1a,Ag3lV,AiWnl,AE6oI :%*[email protected] */
  
  if (cargc<2) {
    Error("channel",ERR_WARNING,"Burst message with only %d parameters",cargc);
    return CMD_OK;
  }
  
  timestamp=strtol(cargv[1],NULL,10);
  
  if ((cp=findchannel(cargv[0]))==NULL) {
    /* We don't have this channel already */
    cp=createchannel(cargv[0]);
    cp->timestamp=timestamp;
    isnewchan=1;
  } else {
    isnewchan=0;
    if (timestamp<cp->timestamp) {
      /* The incoming timestamp is older.  Erase all our current channel modes, and the topic. */
      cp->timestamp=timestamp;
      freesstring(cp->topic);
      cp->topic=NULL;
      cp->topictime=0;
      freesstring(cp->key);
      cp->key=NULL;
      cp->limit=0;
      cp->flags=0;
      clearallbans(cp);
      /* Remove all +v, +o we currently have */
      for(i=0;i<cp->users->hashsize;i++) {
        if (cp->users->content[i]!=nouser) {
          cp->users->content[i]&=CU_NUMERICMASK;
        }
      }
    } else if (timestamp>cp->timestamp) {
      /* The incoming timestamp is greater.  Ignore any incoming modes they may happen to set */
      wipeout=1;
    }
  }

  /* OK, dealt with the name and timestamp. 
   * Loop over the remaining args */
  for (arg=2;arg<cargc;arg++) {
    if (cargv[arg][0]=='+') {
      /* Channel modes */
      if (wipeout) {
        /* We ignore the modes, but we need to see if they include +l or +k 
         * so that we can ignore their corresponding values */
        for (charp=cargv[arg];*charp;charp++) {
          if (*charp=='k' || *charp=='l') {
            arg++;
          }
        }
      } else {
        /* Clear off the limit and key flags before calling setflags so we can see if the burst tried to set them */
        /* If the burst doesn't set them, we restore them afterwards */
        waslimit=IsLimit(cp); ClearLimit(cp);
        waskeyed=IsKey(cp);   ClearKey(cp);
        /* We can then use the flag function for these modes */
        setflags(&(cp->flags),CHANMODE_ALL,cargv[arg],cmodeflags,REJECT_NONE);
        /* Pick up the limit and key, if they were set.  Note that the limit comes first */
        if (IsLimit(cp)) { /* A limit was SET by the burst */
          if (++arg>=cargc) {
            /* Ran out of args -- damn ircd is spewing out crap again */
            Error("channel",ERR_WARNING,"Burst +l with no argument");
            break; /* "break" being the operative word */
          } else {
            newlimit=strtol(cargv[arg],NULL,10);
          }
          if (cp->limit>0 && waslimit) {
            /* We had a limit before -- we now have the lowest one of the two */
            if (newlimit<cp->limit) {
              cp->limit=newlimit;
            }
          } else {
            /* No limit before -- we just have the new one */
            cp->limit=newlimit;
          }
        } else if (waslimit) {
          SetLimit(cp); /* We had a limit before, but the burst didn't set one.  Restore flag. */
        }
        
        if (IsKey(cp)) { /* A key was SET by the burst */
          if (++arg>=cargc) {
            /* Ran out of args -- oopsie! */
            Error("channel",ERR_WARNING,"Burst +k with no argument");
            break;
          }
          if (waskeyed) {
            /* We had a key before -- alphabetically first wins */
            if (ircd_strcmp(cargv[arg],cp->key->content)<0) {
              /* Replace our key */
              freesstring(cp->key);
              cp->key=getsstring(cargv[arg],KEYLEN);
            }
          } else {
            /* No key before -- just the new one */
            cp->key=getsstring(cargv[arg],KEYLEN);
          }
        } else if (waskeyed) {
          SetKey(cp); /* We had a key before, but the burst didn't set one.  Restore flag. */
        }
      }       
    } else if (cargv[arg][0]=='%') {
      /* We have one or more bans here */
      nextnum=cargv[arg]+1;
      while (*nextnum) {
        /* Split off the next ban */
        for (charp=nextnum;*charp;charp++) {
          if (*charp==' ') {
            *charp='\0';
            charp++;
            break;
          }
        }        
        setban(cp,nextnum);
        nextnum=charp;
      }
    } else {
      /* List of numerics */
      nextnum=charp=cargv[arg];
      currentmode=0;
      while (*nextnum!='\0') {
        /* Step over the next numeric */
        for (i=0;i<5;i++) {
          if (*charp++=='\0')
            break;
        }
        if (i<5) {
          break;
        }
        if (*charp==',') {
          *charp='\0';
          charp++;
        } else if (*charp==':') {
          *charp='\0';
          charp++;
          currentmode=0;
          /* Look for modes */
          for (;*charp;charp++) {
            if (*charp=='v') {
              currentmode|=CUMODE_VOICE;
            } else if (*charp=='o') {
              currentmode|=CUMODE_OP;
            } else if (*charp==',') {
              charp++;
              break;
            }
          }
          /* If we're ignore incoming modes, zap it to zero again */
          if (wipeout) {
            currentmode=0;
          }
        }
        /* OK.  At this point charp points to either '\0' if we're at the end,
         * or the start of the next numeric otherwise.  nextnum points at a valid numeric
         * we need to add, and currentmode reflects the correct mode */
        addnicktochannel(cp,(numerictolong(nextnum,5)|currentmode));
        nextnum=charp;
      }
    }
  }
  if (cp->users->totalusers==0) {
    /* Oh dear, the channel is now empty.  Perhaps one of those 
     * charming empty burst messages you get sometimes.. */
    if (!isnewchan) {
      /* I really don't think this can happen, can it..? */
      /* Only send the LOSTCHANNEL if the channel existed before */
      triggerhook(HOOK_CHANNEL_LOSTCHANNEL,cp);
    }
    delchannel(cp);
  } else {
    /* If this is a new channel, we do the NEWCHANNEL hook also */
    if (isnewchan) {
      triggerhook(HOOK_CHANNEL_NEWCHANNEL,cp);
    }
    /* Just one hook to say "something happened to this channel" */
    triggerhook(HOOK_CHANNEL_BURST,cp);       
  }
   
  return CMD_OK;     
}
Пример #23
0
    bool IsRequestedBy(const FactoryBase* factory, const std::string& ename, const FactoryBase* requestedBy) const {
      if (!IsKey(factory, ename))
        return false;

      return IsRequestedBy(Get(factory, ename), requestedBy);
    }
Пример #24
0
int 
GetKey(void)
{
    return IsKey()? getch() : 0;
}