Example #1
0
CMyString CMyString::SubString(size_t start, size_t length)const
{
	if (length > 0 && start >= 0 && start + length < m_length)
	{
		return CMyString(&m_chars[start], length);
	}
	return CMyString();
}
Example #2
0
CMyString CCreateData::RandName()
{
    srand(time(NULL));    
    char szName[32] = {'\0'};
    const char *szBuf[] = {
        "Zhang", 
        "Wang",
        "Li",
        "Zhao",
        "Liu"
    };
    int nIndex = rd.Rand() % 5;
    //生成姓氏
    strcpy(szName, szBuf[nIndex]);
    //生成名字
    int nLen = rd.Rand() % 10;
    int i = 0;
    int k = 0;
    while (1)
    {
        if (szName[i] == '\0')
        {
            szName[i] = (rd.Rand() % (0x7e - 0x20)) + 0x20;
            k++;
        }
        i++;
        if (k == nLen)
        {
            break;
        }
    }
    return CMyString(szName);
}
Example #3
0
bool MainUrlRule::FilterCheck(const char *parentUrl,const char *url)
{
	if(!m_HostCount)
		m_HostCount	=sizeof(m_HostList)/sizeof(CMyString);
	CMyString host=CUrl::GetUrlHost(CMyString((char*)url));
	for(int i=0;i<m_HostCount;i++)
	{
		if(host==m_HostList[i])
		{
			return true;
		}
	}
//	printf("skip url:%s\n",url);
	return false;
}
Example #4
0
	my_string_have_the_addition_operator_()
	{
		stlAddStr = std::string("STL") + CMyString(" string");
		charArrAddStr = "CHAR*" + CMyString(" string");
		myAddStr = CMyString("MY") + CMyString(" string");
	}
Example #5
0
	my_string_can_be_moved_from_rvalue_my_str_()
		: myString(CMyString("Test String", 11u))
	{
	};
Example #6
0
//////////////////////////////////////////////////////////////////////////////
// WMIBaseProvider::getQueryString - builds the query string from the
//		input parameters for Associator and Reference commands
//
// ///////////////////////////////////////////////////////////////////////////
String WMIBaseProvider::getQueryString(const CIMObjectPath &objectName,
		const String &sQueryCommand,							   
		const String &assocClass, 
		const String &resultClass, 
		const String &role,
		const String &resultRole)
{
	bool hasWHERE = false;
	bool isInst;

	//first we need to get the object name
	String sObjName = getObjectName(objectName);

	// check if is an instance name
	Uint32 pos = sObjName.find(qString(Q_PERIOD));
	isInst = (PEG_NOT_FOUND != pos);

	CMyString sQuery;
	sQuery.Format(CMyString(sQueryCommand), 128, CMyString(sObjName));

	//set up any optional parameters
	if (!((0 == assocClass.size()) && (0 == resultClass.size()) &&
		  (0 == role.size()) && (0 == resultRole.size())))
	{	
		// we have optional parameters, append the appropriate ones
		sQuery += qChar(Q_WHERE);
		hasWHERE = true;

		if (0 != assocClass.size())
		{
			sQuery += qChar(Q_ASSOC_CLS);
			sQuery += assocClass;
		}

		if (0 != resultClass.size())
		{
			sQuery += qChar(Q_RESULT_CLASS);
			sQuery += resultClass;
		}

		if (0 != role.size())
		{
			sQuery += qChar(Q_ROLE);
			sQuery += role;
		}

		if (0 != resultRole.size())
		{
			sQuery += qChar(Q_RESULT_ROLE);
			sQuery += resultRole;
		}
	}

	// check if an instance
	if (!isInst)
	{
		// have a class, add "SchemaOnly"
		if (!hasWHERE)
		{
			sQuery += qChar(Q_WHERE);
		}

		sQuery += qChar(Q_SCHEMA);
	}

	Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
		"WMIBaseProvider::getQueryString() - Query is %s", (LPCTSTR)sQuery); 

	String s = (LPCTSTR)sQuery;
	return s;
}
Example #7
0
char*					  TAG="Spider";
CMyString				  g_SlefPath;

//host规则,过滤外部链接
class MainUrlRule:public ISpiderUrlFilter
{
public:
	static CMyString		m_HostList[];
	static int				m_HostCount;
public:
	virtual bool FilterCheck(const char *parentUrl,const char *url);
};
int			MainUrlRule::m_HostCount=0;
CMyString	MainUrlRule::m_HostList[]={
	CMyString("www.920mm.com"),
	CMyString("pic.920mm.com"),
	CMyString("img.920mm.com")
};

bool MainUrlRule::FilterCheck(const char *parentUrl,const char *url)
{
	if(!m_HostCount)
		m_HostCount	=sizeof(m_HostList)/sizeof(CMyString);
	CMyString host=CUrl::GetUrlHost(CMyString((char*)url));
	for(int i=0;i<m_HostCount;i++)
	{
		if(host==m_HostList[i])
		{
			return true;
		}