예제 #1
0
bool RedisClient::eval( CResult& values , const string& script , const VecString& keysVec ,
		const VecString& argsVec )
{
	BuildCommand cmd("EVAL");
	string status;
	int len = keysVec.size();

	cmd << script << len;
	for ( int i = 0 ; i < len ; i++ )
	{
		cmd << keysVec[i];
	}

	len = argsVec.size();
	for ( int i = 0 ; i < len ; i++ )
	{
		cmd << argsVec[i];
	}

	return _getReply(values,cmd);
}
예제 #2
0
VecString RegKey::getSubkeyNames() const
{
  VecString v;
  DWORD i = 0;

  while(true)
  {
    DWORD len = 4096;
    char name[len];
    LONG result = RegEnumKeyEx( m_hkey, i++, name, &len, NULL, NULL, NULL, NULL );

    if( result == ERROR_NO_MORE_ITEMS )
      break;

    if( result != ERROR_SUCCESS )
      throw std::runtime_error( "error iterating keys in " + m_name );

    v.push_back( String(name, name+len) );
  }

  return v;
}
예제 #3
0
bool RedisClient::sort( const string& key , VecString& values , const bool& desc )
{
	BuildCommand cmd("SORT");
	cmd << key;

	if ( desc )
		cmd << "DESC";

	if ( _getArry(cmd, values) )
	{
		return values.size();
	}
	return false;
}
예제 #4
0
int main( VecString args )
{
    bool showall = false;
    bool compact = false;
    //bool recovery = false;

    for( VecString::size_type n=1; n!=args.size(); n++ )
    {
        StringRef opt = args[n];
        if( opt == "-h" ) {
            usage();
            return 0;
        }
        else if( opt == "-l" ) {
            showall = true;
        }
        else if( opt == "-c" ) {
            compact = true;
        }
        else if( opt == "-c" ) {
            compact = true;
        }
        else {
            usage();
            throw std::runtime_error("unknown command line option "+opt);
        }
    }

    ListDevice devs = getDevices();

    if( showall == false )
        devs = getActiveDevices( devs );

    devs.sort();

    if( devs.empty() )
    {
        cout << "No devices found." << endl;
        return 2;
    }
    else if( compact )
        printDevices( devs );
    else
        prettyPrintDevices( devs );

    return 0;
}
예제 #5
0
int getRefCount( const RegKey& dclass, const RegKey& key )
{
  int refcnt = 0;

  try
  {
    String symstr = key["Device Parameters"]("SymbolicName").data;
    VecString sym = split( "\\#", symstr );

    if( sym.size() >= 4 )
    {
      sym.erase( sym.begin(), sym.begin()+sym.size()-4 );
      String devstr = sym[3] +"\\##?#" + join("#",sym) + "\\Control";
      RegKey ctrl = dclass[devstr];
      refcnt = strtol( ctrl("ReferenceCount").data.c_str(), NULL, 0 );
    }
  }
  catch( std::runtime_error e ) { }

  return refcnt;
}
예제 #6
0
bool DatasetCommand::run()
{
	VecString vecXlsxDir;
	Utility_split(m_strFromDir.c_str(), ",", vecXlsxDir);
	
	// 获取所有需要导出的Xlsx
	VecString files;
	for(auto i = 0; i < vecXlsxDir.size(); i++)
	{
		Utility_Find(vecXlsxDir[i].c_str(), files, true, "*.xlsx");
	}


	for(auto i = 0; i < files.size(); i++)
	{
		ParseXlsx(files[i].c_str());
	}

	
		// 导出代码
		if(m_strCodeDir.size() > 0)
		{
			CreatDir((char*)m_strCodeDir.c_str());

			std::string strDBDefine;

			strDBDefine = ""
				"#ifndef _DBDefine_Automake_H_\r\n"
				"#define _DBDefine_Automake_H_\r\n";

			strDBDefine += "\r\nstruct IDBBlock{};\r\n";

			strDBDefine += "enum TableType\r\n{\r\n";
			for(auto itrProps = m_mapTable.begin(); itrProps != m_mapTable.end(); ++itrProps)
			{
				auto vecPropertys = itrProps->second;
				if(vecPropertys.size() == 0)
					continue;

				strDBDefine += "\tTT_";
				std::string strName = itrProps->first;
				strDBDefine += strupr((char*)strName.c_str());
				strDBDefine += ",\r\n";
			}

			strDBDefine += "\tTT_Amount";
			strDBDefine += "\r\n};\r\n\r\n";

			
			for(auto itrProps = m_mapTableEnum.begin(); itrProps != m_mapTableEnum.end(); ++itrProps)
			{
				auto vecPropertys = itrProps->second;
				if(vecPropertys.size() == 0)
					continue;
				std::string strTableName = itrProps->first.c_str();
				strupr((char*)strTableName.c_str());
				std::string strEnumName = "EDT_";
				strEnumName+=strTableName;

				strDBDefine += "enum EDT_";
				strDBDefine += strTableName;
				strDBDefine += "\r\n{\r\n";
				
				for(auto i = 0; i < vecPropertys.size(); i++)
				{
					auto &enumData = vecPropertys[i];
					strDBDefine += "\tEDT_";
					strDBDefine += strTableName;
					strDBDefine += "_";
					strDBDefine += strupr((char*)enumData.strName.c_str());
					strDBDefine += "\t = \t";
					strDBDefine += strupr((char*)enumData.strType.c_str());
					strDBDefine += ", //";
					strDBDefine += strupr((char*)enumData.strDesc.c_str());
					strDBDefine += "\r\n";
				}
				strDBDefine += "};\r\n\r\n";
			}

			for(auto itrProps = m_mapTable.begin(); itrProps != m_mapTable.end(); ++itrProps)
			{
				auto vecPropertys = itrProps->second;
				if(vecPropertys.size() == 0)
					continue;

				strDBDefine += "struct DBData_";
				strDBDefine += itrProps->first;
				strDBDefine += " : IDBBlock";
				
				strDBDefine += "\r\n{\r\n";
				
				for(auto i = 0; i < vecPropertys.size(); i++)
				{
					strDBDefine += "\t";					
					if(vecPropertys[i].strType == "string")
					{
						strDBDefine += "const char*";		
					}
					else
					{
						strDBDefine += vecPropertys[i].strType;					
					}
					strDBDefine += " ";
					strDBDefine += vecPropertys[i].strName;
					strDBDefine += ";//";
					strDBDefine += vecPropertys[i].strDesc;		
					if(i+1 != vecPropertys.size())
						strDBDefine += "\r\n";
				}
				
				strDBDefine += "\r\n};\r\n\r\n";

			}


			strDBDefine += ""
				"#endif";

			Utility_ConvertUtf8ToGBK(strDBDefine);
			FILE *fp = fopen((m_strCodeDir+"DBDefine.h").c_str(), "wb");

			fwrite(strDBDefine.c_str(), strDBDefine.size(), 1, fp);

			fclose(fp);
		}
		
		// 导出csv的表名数据
		if(m_strCSVDir.size() > 0)
		{
			FILE *fp = fopen((m_strCSVDir+"_index").c_str(), "wb");

			int nCount = m_mapTable.size();
			fwrite(&nCount, sizeof(nCount), 1, fp);
			
			for(auto itrProps = m_mapTable.begin(); itrProps != m_mapTable.end(); ++itrProps)
			{
				char cLength = itrProps->first.size();
				fwrite(&cLength, sizeof(cLength), 1, fp);
				fwrite(itrProps->first.c_str(), cLength, 1, fp);
			}

			fclose(fp);
		}

	return true;
}