Example #1
0
Storage::Prefix Storage::prefix(const std::string& name)
{
	if(name.empty())
		return Prefix(this, prefixByName_.begin());

	return Prefix(this, prefixByName_.find(name));
}
Example #2
0
Storage::Prefix Storage::Prefix::next() const
{
	if(storage_ && it_ != storage_->prefixByName_.end()) {
		auto nextIt = it_;
		return Prefix(storage_, ++nextIt);
	}

	return Prefix();
}
Example #3
0
Storage::Prefix Storage::createPrefix(const std::string& name, const std::string& path)
{
	auto it = prefixByName_.find(name);
	if(it != prefixByName_.end())
		return Prefix();

	auto result = prefixByName_.emplace(name, path);
	isChanged_ = true;
	return Prefix(this, result.first);
}
Example #4
0
int wxCheckListBox::FindString(const wxString& s, bool bCase) const
{
    int n1 = wxListBox::FindString(Prefix(false) + s, bCase);
    int n2 = wxListBox::FindString(Prefix(true) + s, bCase);
    int min = wxMin(n1, n2), max = wxMax(n1, n2);

    // why this works:
    // n1 == -1, n2 == -1 => return -1 OK
    // n1 != -1 || n2 != -1 => min == -1 => return the other one
    // both != -1 => return the first one.
    if( min == -1 ) return max;
    return min;
}
Example #5
0
Verbose &Verbose::Print(rcString inMsg, Level inLevel)
{
  if (inLevel < sMinLevel)
    return *this;

  if (sOutput & LOG && sStream.is_open() && sStream.good())
  {
    if (mIsStartOfLine)
      sStream << Prefix(inLevel) << inMsg;
    else
      sStream << inMsg;

    sStream.flush();
  }

  if (sOutput & SCREEN)
  {
    std::string output;

    if (sShouldUseColor)
      output = ColorizeLevel(inMsg, inLevel);
    else
      if (mIsStartOfLine)
        output = Prefix(inLevel) + inMsg;
      else
        output = inMsg;

    switch (inLevel)
    {
    case ERR:
      {
        std::cerr << output << std::flush;
        break;
      }
    case FTL:
      {
        std::cerr << output << std::flush;
        exit(EXIT_FAILURE);
        break;
      }
    default:
      {
        std::cout << output << std::flush;
        break;
      }
    }
  }

  mIsStartOfLine = (inMsg.find('\n') != std::string::npos);
  return *this;
}
Example #6
0
		virtual void Visit(Switch& instruction)
		{
			Prefix(instruction);
			mOut << "switch (";
			instruction.Operand()->GenerateCode(mOut);
			mOut << ')' << std::endl;
		}
Example #7
0
		virtual void Visit(Return& instruction)
		{
			Prefix(instruction);
			mOut << "return ";
			instruction.Operand()->GenerateCode(mOut);
			mOut << ';' << std::endl;
		}
Example #8
0
		virtual void Visit(Pop& instruction)
		{
			Prefix(instruction);
			mOut << "/* pop ";
			instruction.Operand()->GenerateCode(mOut);
			mOut << " */" << std::endl;
		}
Example #9
0
		virtual void Visit(LowLevel& instruction)
		{
			Prefix(instruction);
			mOut << "/* Low-level instruction of type " 
				<< instruction.Insn().itype
				<< " */" << std::endl;
		}
Example #10
0
CFunc CFunc::FuncWithBase_InvChannels(CMyString baseName) const
{
   CMyString sBase, sType, sChan1, sChan2, sDescr;
   ParseFunction(sBase, sType, sDescr);
   if (sDescr.IsEmpty())
      return Prefix() + baseName + _T("_") + sType;
   sChan1 = firstChanStr(sDescr);
   sChan2 = firstChanStr(sDescr);
   CFunc func = Prefix() + baseName + _T("_") + sType + _T("_");
   if (sChan2.IsEmpty())
      func += sChan1 ;
   else
      func += sChan2 + sChan1 ;
   func += sDescr;
   return func;
}
Example #11
0
CFunc CFunc::FuncWithBase(CMyString baseName) const
{
   CFunc func = Prefix() + baseName + _T("_") + TypeName();
   if (!DescrName().IsEmpty())
      func += _T("_") + DescrName();
   return func;
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
bool CVProjectUtil::RunStudiomdl(
	const std::string &file )
{
	const std::string game( Prefix() + "/game/" + Game() );
	const std::string src( ModelSrc( file ) );

	const std::string cmd( std::string( "studiomdl -game \"" ) + game + std::string( "\" \"" ) + src + "\"" );

	FILE *cmdp( _popen( cmd.c_str(), "rt" ) );
	if ( !cmdp )
	{
		merr << "Couldn't execute studiomdl command: " << cmd << std::endl;

		return false;
	}

	char buf[ BUFSIZ ];

	while ( !feof( cmdp ) )
	{
		if ( fgets( buf, BUFSIZ, cmdp ) == NULL )
		{
			break;
		}

		minfo << "studiomdl: " << buf;
	}
	minfo << std::endl;

	_pclose( cmdp );

	return true;
}
Example #13
0
void NTPath::Transform()
{
	string& Data = *this;
	if (!Data.empty())
	{
		if(!HasPathPrefix(Data))
		{
			ConvertNameToFull(Data,Data);

			if (!HasPathPrefix(Data))
			{
				ReplaceSlashToBackslash(Data);
				string Prefix(ParsePath(Data) == PATH_DRIVELETTER? L"\\\\?\\" : L"\\\\?\\UNC");
				while(ReplaceStrings(Data,L"\\\\",L"\\"))
					;
				Data=Prefix+Data;
			}
		}
		if(Data.size() > 5 && Data[5] == L':')
		{
			// "\\?\C:" -> "\\?\c:"
			// Some file operations fails on Win2k if a drive letter is in upper case
			ToLower(Data, 4, 1);
		}
	}
}
Example #14
0
		virtual void Visit(Jump& instruction)
		{
			Prefix(instruction);
			mOut << "goto ";
			instruction.Operand()->GenerateCode(mOut);
			mOut << ';' << std::endl;
		}
/**
 * ヘルプを表示
 * @param[in]     settings     コマンドライン読み込み設定コンテナ
 * @param[in]     noPrefixHelp 接頭文字なしの引数に関するヘルプ表示(接頭文字なしの引数が不要であれば空文字"")
 * @param[in,out] outStream    出力先のストリーム
 */
void CommandLineSetting::ShowHelp(
  const std::vector<CommandLineSetting>& settings,
  const std::string& noPrefixHelp,
  std::ostream* outStream)
{
  //----- パラメータの説明 -----//
  // 設定数ループ
  for (auto setting = settings.begin(); setting != settings.end(); ++setting)
  {
    // 接頭文字表示
    *outStream << setting->Prefix() << std::flush;
    // 後続のパラメータが必要な場合は数を表示
    if (setting->NumberOfParameter() > 0)
    {
      *outStream << " (+ " << setting->NumberOfParameter() << " parameters)" << std::flush;
    }
    *outStream << std::endl;
    // ヘルプ表示
    *outStream << setting->Help() << std::endl;
    // 改行
    *outStream << std::endl;
  }
  // 接頭文字なしの引数に関するヘルプ表示
  if (noPrefixHelp != "")
  {
    *outStream << "NO PREFIX" << std::endl;
    // ヘルプ表示
    *outStream << noPrefixHelp << std::endl;
    // 改行
    *outStream << std::endl;
  }
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
std::string CVProjectUtil::ConvertMaterialSrcToVtf(
	const std::string &file )
{
	const std::string game( Prefix() + "/game/" + Game() );
	const std::string src( MaterialSrc( file ) );

	const std::string cmd( std::string( "vtex -mkdir -nopause -game \"" ) + game + std::string( "\" \"" ) + src + "\"" );

	FILE *vtex( _popen( cmd.c_str(), "rt" ) );
	if ( !vtex )
	{
		merr << "Couldn't execute vtex command: " << cmd << std::endl;
		return false;
	}

	char buf[ BUFSIZ ];

	while ( !feof( vtex ) )
	{
		if ( fgets( buf, BUFSIZ, vtex ) == NULL )
		{
			break;
		}

		minfo << "vtex: " << buf;
	}
	minfo << std::endl;

	_pclose( vtex );

	return MaterialDst( src );
}
Example #17
0
		virtual void Visit(ConditionalJump& instruction)
		{
			Prefix(instruction);
			mOut << "if (";
			instruction.First()->GenerateCode(mOut);
			mOut << ") goto ";
			instruction.Second()->GenerateCode(mOut);
			mOut << ';' << std::endl;
		}
Example #18
0
		virtual void Visit(Assignment& instruction)
		{
			Prefix(instruction);
			if (!instruction.First()->IsType(Expression::DUMMY))
			{
				instruction.First()->GenerateCode(mOut);
				mOut << " = ";
			}
			instruction.Second()->GenerateCode(mOut);
			mOut << ';' << std::endl;
		}
Example #19
0
int wxCheckListBox::DoInsertItems(const wxArrayStringsAdapter& items,
                                  unsigned int pos,
                                  void **clientData, wxClientDataType type)
{
    wxArrayString copy;
    copy.reserve(pos);
    for ( size_t i = 0; i < items.GetCount(); ++i )
        copy.push_back( Prefix(false) + items[i] );

    return wxListBox::DoInsertItems(copy, pos, clientData, type);
}
Example #20
0
CFunc CFunc::FuncWithBase_InvType(CMyString baseName) const
{
   CMyString sBase, sType1, sType2, sType3, sDescr;
   ParseFunction(sBase, sType1, sType2, sType3, sDescr);
   CFunc func = Prefix() + baseName + _T("_");
   if (sType1 == sType3)
      func += sType1 ;
   else
      func += sType3 + sType1 ;
   if (!sDescr.IsEmpty())
      func += _T("_") + sDescr;
   return func;
}
EXPORT_C TBool CSenNamespace::Compare(const TDesC8& aOtherPrefix,
                                       const TDesC8& aOtherUri) const
    {
    TBool retVal(EFalse);
    if (aOtherUri == URI())
        {
        if (aOtherPrefix == KNullDesC8 || aOtherPrefix == Prefix())
            {
            retVal = ETrue;
            }
        }
    return retVal;
    }
Example #22
0
		virtual void Visit(Throw& instruction)
		{
			Prefix(instruction);
			if (instruction.IsRethrow())
			{
				mOut << "throw;" << std::endl;
			}
			else
			{
				mOut << "throw ";
				instruction.Exception()->GenerateCode(mOut);
				mOut << "; // " << instruction.DataType() << std::endl;
			}
		}
Example #23
0
// static
void CRDFParser::NameSpaceHandler(void * pGraph, raptor_namespace * pNameSpace)
{
  const unsigned char * pURI =
    raptor_uri_as_string(raptor_namespace_get_uri(pNameSpace));
  std::string URI("");

  if (pURI) URI = (const char *) pURI;

  const unsigned char * pPrefix =
    raptor_namespace_get_prefix(pNameSpace);
  std::string Prefix("");

  if (pPrefix) Prefix = (const char *) pPrefix;

  static_cast<CRDFGraph *>(pGraph)->addNameSpace(Prefix, URI);
}
Example #24
0
void HTokenizer::Tokenize(const DISASM *Instr, QList<Token_t> *Tok)
{
    // clear current list
    Tok->clear();

    //--  Address(Tok,Instr);
    //--  Label(Tok,Instr);

    Prefix(Tok,Instr);

    // get basic instruction like "mov, push, stosb"
    Instruction(Tok,Instr);

    // get arguments in temporary token-lists to place the comma between them if we need one
    QList<Token_t> Arg1, Arg2, Arg3;
    Argument(&Arg1,Instr,Instr->Argument1);
    Argument(&Arg2,Instr,Instr->Argument2);
    Argument(&Arg3,Instr,Instr->Argument3);

    // append the first argument
    *Tok << Arg1;

    // do we need a comma (makes sure, that tere is no comma between push and constant like
    // "push , 10h"
    if(Arg2.count()>0 && Arg1.count() >0){
        Token_t tmp;
        tmp.Text = ", ";
        tmp.Type = T_CHAR;
        Tok->append(tmp);
    }

    // append second argument (can be empty)
    *Tok << Arg2;

    // do we need a comma ?
    if(Arg3.count()>0){
        Token_t tmp;
        tmp.Text = ", ";
        tmp.Type = T_CHAR;
        Tok->append(tmp);
    }

    // append third argument (can be empty)
    *Tok << Arg3;

}
 vector<int> createPrefix(string needle)
 {
     int m=needle.size();
     vector<int>Prefix(m,-1);
     
     int j=-1;
     for (int i=1; i<m; i++)
     {
         while (j>=0 && needle[j+1]!=needle[i])
             j=Prefix[j];            
         if (needle[j+1]==needle[i])
             j++;            
         Prefix[i]=j;            
     }
     
     return Prefix;        
 }
Example #26
0
wxString Dirstructure::ResourcesDir()
{
#if defined __WXMSW__
  wxString exe = wxStandardPaths::Get().GetExecutablePath();
  int lastSlash = exe.rfind(wxT('/'));
  int lastBackslash = exe.rfind(wxT('\\'));
  if (lastSlash < lastBackslash)
    exe = exe.Left(lastBackslash + 1);
  else
    exe = exe.Left(lastSlash + 1);
  return exe;
#elif defined __WXMAC__
  wxString exe = wxStandardPaths::Get().GetExecutablePath();
  exe.Replace(wxT("MacOS/wxmaxima"), wxT("Resources/"));
  return exe;
#else
  return Prefix()+wxT("/share/wxMaxima/");
#endif
}
Example #27
0
int wxCheckListBox::DoInsertItems(const wxArrayStringsAdapter& items,
                                  unsigned int pos,
                                  void **clientData, wxClientDataType type)
{
    wxArrayString copy;
    copy.reserve(pos);
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( size_t i = 0; i < items.GetCount(); ++i )
        copy.push_back( Prefix(false) + items[i] );

    return wxListBox::DoInsertItems(copy, pos, clientData, type);
}
Example #28
0
static
void ToXml(const DataSetElement& node,
           const NamespaceRegistry& registry,
           map<XsdType, string>& xsdPrefixesUsed,
           pugi::xml_node& parentXml)
{
    // create child of parent, w/ label & text
    const string& label = OutputName(node, registry);
    if (label.empty())
        return; // error?
    pugi::xml_node xmlNode = parentXml.append_child(label.c_str());

    if (!node.Text().empty())
        xmlNode.text().set(node.Text().c_str());

    // store XSD type for later
    const string prefix = Prefix(label);
    if (!prefix.empty())
        xsdPrefixesUsed[node.Xsd()] = prefix;

    // add attributes
    auto attrIter = node.Attributes().cbegin();
    auto attrEnd  = node.Attributes().cend();
    for ( ; attrIter != attrEnd; ++attrIter) {
        const string& name = attrIter->first;
        if (name.empty())
            continue;
        pugi::xml_attribute attr = xmlNode.append_attribute(name.c_str());
        attr.set_value(attrIter->second.c_str());
    }

    // additional stuff later? (e.g. comments)

    // iterate children, recursively building up subtree
    auto childIter = node.Children().cbegin();
    auto childEnd  = node.Children().cend();
    for ( ; childIter != childEnd; ++childIter) {
        const DataSetElement& child = (*childIter);
        ToXml(child, registry, xsdPrefixesUsed, xmlNode);
    }
}
Example #29
0
int cServerDC::ValidateUser(cConnDC *conn, const string &nick, int &closeReason)
{
	// first validate the IP and host if any
	stringstream errmsg,os;
	// Default close reason
	closeReason = eCR_INVALID_USER;
	if (!conn) return 0;
	//time_t n;
	bool close=false;

	// phase 1: test nick validity
	// phase 2: test ip/host ban (registered users pass)
	// phase 3: test nickban
	// then we're done

	static cRegUserInfo *sRegInfo = new cRegUserInfo;
	if ((nick.size() < mC.max_nick * 2 ) && mR->FindRegInfo(*sRegInfo,nick) && !conn->mRegInfo ) {
		conn->mRegInfo = sRegInfo;
		sRegInfo = new cRegUserInfo;
	}

	// Validate nick
	tVAL_NICK vn = ValidateNick(nick, (conn->GetTheoricalClass() >= eUC_REGUSER ));
	if(vn != eVN_OK) {
		close=true;
		if(vn == eVN_BANNED) {
			errmsg << _("Do not reconnect too fast.") << " ";
			closeReason = eCR_RECONNECT;
		}
		else
			errmsg << _("Bad nickname") << ": ";
		if (conn->Log(2))
			conn->LogStream() << "Bad nick: '" << nick << "' (" << vn << ")" << endl;
	}
	switch(vn) {
		case eVN_OK:
		break;
		case eVN_CHARS:
			errmsg << _("Unallowed characters in your nick.");
			if(mC.nick_chars.size())
				 errmsg << autosprintf(_("use these: %s"), mC.nick_chars.c_str());
		break;
		case eVN_SHORT:
			errmsg << _("Your nick is too short.");
		break;
		case eVN_LONG:
			errmsg << _("Your nick is too long.");
		break;
		case eVN_USED: // never happens
			errmsg << _("Your nick is already in use.");
		break;
		case eVN_PREFIX:
			errmsg << autosprintf(_("Invalid nick prefix. Use: %s"), mC.nick_prefix.c_str());
		break;
		case eVN_NOT_REGED_OP:
			errmsg << _("Operator not registered.");
		break;
		case eVN_BANNED:
			errmsg << autosprintf(_("Wait %s before reconnecting."), cTime(mBanList->IsNickTempBanned(nick) - cTime().Sec()).AsPeriod().AsString().c_str());
		break;
		default:
			errmsg << _("Unknown error.");
		break;
	}

	if (close) {
		if (vn == eVN_USED) {
			static string omsg;
			omsg = "$ValidateDenide";
			conn->Send(omsg);
		}

		DCPublicHS(errmsg.str(), conn);
		if (conn->Log(3)) conn->LogStream() << "Bad nick: " << errmsg.str() << endl;
		return 0;
	}

	cBan Ban(this);
	bool banned = false;

	if (conn->GetTheoricalClass() < eUC_MASTER) { // master class is immune
		// here we cant check share ban because user hasnt sent $MyINFO yet
		if (conn->GetTheoricalClass() == eUC_NORMUSER)
			banned = mBanList->TestBan(Ban, conn, nick, eBF_NICK | eBF_NICKIP | eBF_RANGE | eBF_HOST2 | eBF_HOST1 | eBF_HOST3 | eBF_HOSTR1 | eBF_PREFIX);
		else // registered users avoid prefix ban check because we might actually ban a prefix for unregistered users, but let registered users to use it
			banned = mBanList->TestBan(Ban, conn, nick, eBF_NICK | eBF_NICKIP | eBF_RANGE | eBF_HOST2 | eBF_HOST1 | eBF_HOST3 | eBF_HOSTR1);
	}

	if (banned) {
		errmsg << _("You are banned from this hub.") << "\r\n";
		Ban.DisplayUser(errmsg);
		DCPublicHS(errmsg.str(), conn);
		if (conn->Log(1)) conn->LogStream() << "Unallowed user (" << Ban.mType << "), closing" << endl;
		return 0;
	}

	if (mC.nick_prefix_cc) {
		if (conn->mCC.size() && conn->mCC != "--") {
			string Prefix("[");
			Prefix += conn->mCC;
			Prefix += "]";

			if (StrCompare(nick, 0, 4, Prefix) != 0) {
				errmsg << autosprintf(_("Please add %s in front of your nick."), Prefix.c_str());
				close = conn->GetTheoricalClass() < eUC_REGUSER;
			}
		}
	}

	if (close) {
		DCPublicHS(errmsg.str(), conn);
		return 0;
	}

	return 1;
}
Example #30
0
LOCALFUN BOOL SwizzleSpace(ADDRINT val)
{
    return Prefix(val) == SwizzlePrefix;
}