예제 #1
0
//
// Returns a vector of strings containing mesh names for this domain
//
StringVec SpeckleyDomain::getMeshNames() const
{
    StringVec res;
    if (initialized) {
        StringVec tmpVec;
        tmpVec = cells->getMeshNames();
        res.insert(res.end(), tmpVec.begin(), tmpVec.end());
        tmpVec = faces->getMeshNames();
        res.insert(res.end(), tmpVec.begin(), tmpVec.end());
    }
    return res;
}
예제 #2
0
/*static*/ bool StructureParser::test_matchCppType () {
	// Test 1 (regression)
	{
		StringVec v = createStringVec ("static std :: pair < string , int > var");
		bool result;
		CppType type;
		StringVec::const_iterator i = matchCppType (v.begin(), v.end(), &result, &type);
		if (!result || i != v.begin() + 9){
			fprintf (stderr, "test_matchCppType1 failed\n");
			markPosition (v.begin(), v.end(), i);
			return false;
		}
	}
	// Test2
	{
		StringVec v = createStringVec ("void");
		bool result;
		CppType type;
		StringVec::const_iterator i = matchCppType (v.begin(), v.end(), &result, &type);
		if (!result || i != v.end()){
			fprintf (stderr, "test_matchCppType2 failed\n");
			markPosition (v.begin(), v.end(), i);
			return false;
		}
	}
	// Test 3 with reference
	{
		StringVec v = createStringVec ("std :: string &");
		bool result;
		CppType type;
		StringVec::const_iterator i = matchCppType (v.begin(), v.end(), &result, &type);
		if (!result || i != v.end()){
			fprintf (stderr, "test_matchCppType3 failed: %d %s\n", result, sf::toJSON (type).c_str());
			markPosition (v.begin(), v.end(), i);
			return false;
		}
	}
	// Test 4 const reference
	{
		StringVec v = createStringVec ("const std :: string & bla");
		bool result;
		CppType type;
		StringVec::const_iterator i = matchCppType (v.begin(), v.end(), &result, &type);
		if (!result || i != v.begin() + 5){
			fprintf (stderr, "test_matchCppType4 failed: %d %s\n", result, sf::toJSON (type).c_str());
			markPosition (v.begin(), v.end(), i);
			return false;
		}
	}

	return true;
}
예제 #3
0
int D_Typeface::lua_WordWrap(lua_State *L) {
	D_Typeface::Ref self = lua::SharedPtr::Get<D_Typeface>(L, "D_Typeface", 1, true);

	bool kern = (lua_gettop(L) < 4) || (lua_toboolean(L, 4) ? true : false);
	float kernScale = (lua_gettop(L) < 5) ? 1.f : (float)luaL_checknumber(L, 5);

	self->typeface->font->SetPixelSize(
		self->typeface->width,
		self->typeface->height
	);

	StringVec strings = self->typeface->font->WordWrapString(
		luaL_checkstring(L, 2),
		(float)luaL_checknumber(L, 3),
		kern,
		kernScale
	);

	if (strings.empty())
		return 0;

	int ofs = 1;
	lua_createtable(L, (int)strings.size(), 0);
	for (StringVec::const_iterator it = strings.begin(); it != strings.end(); ++it) {
		lua_pushinteger(L, ofs++);
		lua_pushstring(L, (*it).c_str);
		lua_settable(L, -3);
	}

	return 1;
}
void getRelativePaths(const String& fromAbsPath, StringVec& toAbsPaths)
{
  StringVec::iterator pathsIt = toAbsPaths.begin();
  for (; pathsIt != toAbsPaths.end(); pathsIt++) {
    *pathsIt = getRelativePath(fromAbsPath, *pathsIt);
  }
}
예제 #5
0
void processClangFlags(String& clangFlags, const String& absProjDirOld, const String& absProjDirNew) {
    // Tokenize the flags
    StringVec clangFlagTokens;
    tokenize(clangFlags, clangFlagTokens, " \t", "", "\"'", "", "", true, false);
    reduceClangTokens(clangFlagTokens);

    auto tokensIt = clangFlagTokens.begin();
    while (tokensIt != clangFlagTokens.end()) {
        if (strBeginsWith(*tokensIt, "-iquote")) {
            String newPath = makeRelativePath(tokensIt->substr(7), absProjDirOld, absProjDirNew);
            *tokensIt = "-iquote" + quoteIfNeeded(newPath);
        } else if (strBeginsWith(*tokensIt, "-I")) {
            String newPath = makeRelativePath(tokensIt->substr(2), absProjDirOld, absProjDirNew);
            *tokensIt = "-I" + quoteIfNeeded(newPath);
        } else if (strBeginsWith(*tokensIt, "-F")) {
            tokensIt = clangFlagTokens.erase(tokensIt);
            continue; // don't increment iterator
        } else {
            *tokensIt = quoteIfNeeded(*tokensIt);
        }

        tokensIt++;
    }

    clangFlags = joinStrings(clangFlagTokens, " ");
}
예제 #6
0
파일: monsters.cpp 프로젝트: milbradt/TFS
bool Monsters::loadLoot(xmlNodePtr node, LootBlock& lootBlock)
{
	std::string strValue;
	if(readXMLString(node, "id", strValue) || readXMLString(node, "ids", strValue))
	{
		IntegerVec idsVec;
		parseIntegerVec(strValue, idsVec);
		for(IntegerVec::iterator it = idsVec.begin(); it != idsVec.end(); ++it)
		{
			lootBlock.ids.push_back(*it);
			if(Item::items[(*it)].isContainer())
				loadChildLoot(node, lootBlock);
		}
	}
	else if(readXMLString(node, "name", strValue) || readXMLString(node, "names", strValue))
	{
		StringVec names = explodeString(strValue, ";");
		for(StringVec::iterator it = names.begin(); it != names.end(); ++it)
		{
			uint16_t tmp = Item::items.getItemIdByName(strValue);
			if(!tmp)
				continue;

			lootBlock.ids.push_back(tmp);
			if(Item::items[tmp].isContainer())
				loadChildLoot(node, lootBlock);
		}
	}

	if(lootBlock.ids.empty())
		return false;

	int32_t intValue;
	if(readXMLInteger(node, "count", intValue) || readXMLInteger(node, "countmax", intValue))
		lootBlock.count = intValue;
	else
		lootBlock.count = 1;

	if(readXMLInteger(node, "chance", intValue) || readXMLInteger(node, "chance1", intValue))
		lootBlock.chance = std::min(MAX_LOOTCHANCE, intValue);
	else
		lootBlock.chance = MAX_LOOTCHANCE;

	if(readXMLInteger(node, "subtype", intValue) || readXMLInteger(node, "subType", intValue))
		lootBlock.subType = intValue;

	if(readXMLInteger(node, "actionId", intValue) || readXMLInteger(node, "actionid", intValue)
		|| readXMLInteger(node, "aid", intValue))
		lootBlock.actionId = intValue;

	if(readXMLInteger(node, "uniqueId", intValue) || readXMLInteger(node, "uniqueid", intValue)
		|| readXMLInteger(node, "uid", intValue))
		lootBlock.uniqueId = intValue;

	if(readXMLString(node, "text", strValue))
		lootBlock.text = strValue;

	return true;
}
예제 #7
0
IntegerVec vectorAtoi(StringVec stringVector)
{
	IntegerVec returnVector;
	for(StringVec::iterator it = stringVector.begin(); it != stringVector.end(); ++it)
		returnVector.push_back(atoi((*it).c_str()));

	return returnVector;
}
예제 #8
0
IntegerVec vectorAtoi(const StringVec& stringVector)
{
    IntegerVec returnVector;
    for (auto it = stringVector.begin(); it != stringVector.end(); ++it) {
        returnVector.push_back(atoi(it->c_str()));
    }
    return returnVector;
}
예제 #9
0
MountInfoVec getMountInfo()
{
    int exitCode;
    
    StringVec tcOutput = splitToLines(executeCommand("truecrypt", "-l", exitCode));

    if(exitCode != 0)
    {
        if(tcOutput.size() > 0)
        {
            throw std::runtime_error(tcOutput[0]);
        }
        else
        {
            throw std::runtime_error("unknown error while querying mounted images");
        }
    }
    
    StringVec mntOutput = splitToLines(executeCommand("mount", exitCode));
    MountInfoVec info;
    
    for(StringVec::const_iterator tcIt = tcOutput.begin(); tcIt != tcOutput.end(); ++tcIt)
    {
        StringVec tcWords = splitToWords(*tcIt);
        
        std::string device = tcWords[0];
        std::string image = tcWords[1];
        
        for(StringVec::const_iterator mntIt = mntOutput.begin(); mntIt != mntOutput.end(); ++mntIt) 
        {
            StringVec mntWords = splitToWords(*mntIt);
            
            std::string mntDev = mntWords[0];
            std::string mntPoint = mntWords[2];
            
            if(mntDev == device)
            {
                info.push_back(MountInfo(image, mntPoint));
                break;
            }
        }
    }

    return info;
}
예제 #10
0
int SkAnimSetParser::Load(
	const xtime::TimeSlice &time,
	Engine &engine,
	const pkg::Asset::Ref &asset,
	int flags
) {
	const String *s = asset->entry->KeyValue<String>("Source.File", P_TARGET_FLAGS(flags));
	if (!s)
		return SR_MetaError;

	StringVec sourceVec;
	tools::SkaCompressionMap compression;

	int r = LoadToolsFile(
		s->c_str,
		engine,
		&sourceVec,
		&compression
	);

	if (r != SR_Success)
		return r;

	tools::SceneFileVec sources;

	for (StringVec::const_iterator it = sourceVec.begin(); it != sourceVec.end(); ++it) {
	
		file::MMFileInputBuffer::Ref scene = engine.sys->files->OpenInputBuffer((*it).c_str, ZTools);

		if (!scene) {
			COut(C_Error) << "ERROR: Unable to open file '" << *it << "'" << std::endl;
			return SR_FileNotFound;
		}

		stream::InputStream is(*scene);
		tools::SceneFileRef source(new (ZTools) tools::SceneFile());

		if (!tools::LoadSceneFile(is, *source, false))
			return SR_ParseError;

		if (source->worldspawn->models.size() != 1) {
			COut(C_Error) << "ERROR: 3DX file should only contain 1 model, it contains " << source->worldspawn->models.size() << ". File: '" << *it << "'" << std::endl;
			return SR_ParseError;
		}

		sources.push_back(source);
	}

	m_skad = tools::CompileSkaData(
		asset->name,
		sources,
		0,
		&compression
	);

	return m_skad ? SR_Success : SR_ParseError;
}
예제 #11
0
// "Expand" -Wl and -Xlinker tokens
// This is OK to do since we're interested in a small subset of flags.
// Preserving correctness is not important.
static void replaceWlArgs(const StringVec& inArgs, StringVec& outArgs) {
    for (auto arg : inArgs) {
        if (strBeginsWith(arg, "-Wl,")) {
            StringVec tokens;
            tokenize(arg, tokens, ",", "", "", "", "");
            outArgs.insert(outArgs.end(), tokens.begin() + 1, tokens.end());
        } else if (arg != "-Xlinker") {
            outArgs.push_back(arg);
        }
    }
}
예제 #12
0
void Spectators::kick(StringVec list)
{
	for(StringVec::const_iterator it = list.begin(); it != list.end(); ++it)
	{
		for(SpectatorList::iterator sit = spectators.begin(); sit != spectators.end(); ++sit)
		{
			if(asLowerCaseString(sit->second.first) == *it)
				sit->first->disconnect();
		}
	}
}
예제 #13
0
파일: tools.cpp 프로젝트: milbradt/TFS
IntegerVec vectorAtoi(StringVec stringVector)
{
	IntegerVec returnVector;
	for(StringVec::iterator it = stringVector.begin(); it != stringVector.end(); ++it)
	{
		int32_t number = atoi((*it).c_str());
		if(number || (*it) == "0")
			returnVector.push_back(number);
	}

	return returnVector;
}
예제 #14
0
파일: MojDbKind.cpp 프로젝트: webOS101/db8
MojErr MojDbKind::diffSupers(const KindMap& map, const StringVec& vec1, const StringVec& vec2, KindVec& diffOut)
{
	for (StringVec::ConstIterator i = vec1.begin(); i != vec1.end(); ++i) {
		if (vec2.find(*i) == MojInvalidIndex) {
			KindMap::ConstIterator kindIter = map.find(*i);
			if (kindIter != map.end()) {
				MojErr err = diffOut.push(kindIter->get());
				MojErrCheck(err);
			}
		}
	}
	return MojErrNone;
}
예제 #15
0
static String reduceLinkerToken(const String& token) {
    static const char* const _prefixes[] = { "-weak", "-reexport", "-lazy", "-upward" };
    static StringVec prefixes(_prefixes, _prefixes + sizeof(_prefixes) / sizeof(char*));

    StringVec::const_iterator pIt = prefixes.begin();
    for (; pIt != prefixes.end(); ++pIt) {
        size_t prefixLen = pIt->length();
        if (token.length() > prefixLen && strBeginsWith(token, *pIt) && (token[prefixLen] == '_' || token[prefixLen] == '-'))
            return "-" + token.substr(prefixLen + 1);
    }

    return token;
}
예제 #16
0
void Spectators::ban(StringVec _bans)
{
	StringVec::const_iterator it;
	for(DataList::iterator bit = bans.begin(); bit != bans.end(); )
	{
		it = std::find(_bans.begin(), _bans.end(), bit->first);
		if(it == _bans.end())
			bans.erase(bit++);
		else
			++bit;
	}

	for(it = _bans.begin(); it != _bans.end(); ++it)
	{
		for(SpectatorList::const_iterator sit = spectators.begin(); sit != spectators.end(); ++sit)
		{
			if(asLowerCaseString(sit->second.first) != *it)
				continue;

			bans[*it] = sit->first->getIP();
			sit->first->disconnect();
		}
	}
}
예제 #17
0
static void reduceClangTokens(StringVec& otherFlagTokens) {
    String savedToken;
    auto tokensIt = otherFlagTokens.begin();
    while (tokensIt != otherFlagTokens.end()) {
        if (!savedToken.empty()) {
            *tokensIt = savedToken + *tokensIt;
            savedToken.clear();
        } else if (*tokensIt == "-I" || *tokensIt == "-iquote" || *tokensIt == "-F") {
            savedToken = *tokensIt;
            tokensIt = otherFlagTokens.erase(tokensIt);
            continue; // don't increment iterator
        }

        tokensIt++;
    }
}
예제 #18
0
/*static*/ bool StructureParser::test_matchTypeName () {
	// Test 1
	{
		StringVec v = createStringVec ("int");
		bool result;
		StringVec::const_iterator i = matchTypeName (v.begin(), v.end(), &result);
		if (!result || i != v.end()){
			fprintf (stderr, "test_matchTypeName1 failed\n");
			return false;
		}
	}
	// Test 2 (more complex)
	{
		StringVec v = createStringVec ("std :: vector < std :: string > notInType");
		bool result;
		StringVec::const_iterator i = matchTypeName (v.begin(), v.end(), &result);
		if (!result || i != v.begin() + 8){
			fprintf (stderr, "test_matchTypeName2 failed\n");
			markPosition (v.begin(),v.end(), i);
			return false;
		}
	}
	{
		StringVec v = createStringVec ("std :: string x");
		bool result;
		StringVec::const_iterator i = matchTypeName (v.begin(), v.end(), &result);
		if (!result || i != v.begin() + 3){
			fprintf (stderr, "test_matchTypeName3 failed\n");
			markPosition (v.begin(), v.end(), i);
			return false;
		}
	}
	// Test 4 failing parsing
	{
		StringVec v = createStringVec ("std :: vector < < std :: astring > notInType");
		// missing '>'
		bool result;
		/*StringVec::const_iterator i = */ matchTypeName (v.begin(), v.end(), &result);
		if (result){
			fprintf (stderr, "test_matchTypeName4 failed\n");
			return false;
		}
	}
	return true;
}
예제 #19
0
  std::string Path::normalize(const std::string & path)
  {
    // Easiest way is: split, then remove "." and remove a/.. (but not ../.. !)
    // This does not get a/b/../.. so if we remove a/.., go through the string again
    // Also need to treat rootdir/.. specially
    // Also normalize(foo/..) -> "." but normalize(foo/bar/..) -> "foo"
    StringVec v = Path::split(path);
    if (v.size() == 0) 
      return "";

    StringVec outv;
    bool doAgain = true;
    while (doAgain) 
    {
      doAgain = false;
      for (unsigned int i = 0; i < v.size(); i++) 
      {
        if (v[i] == "") continue; // remove empty fields
        if (v[i] == "." && v.size() > 1) continue; // skip "." unless it is by itself
        if (i == 0 && isRootdir(v[i]) && i+1 < v.size() && v[i+1] == "..") 
        {
          // <root>/.. -> <root>
          outv.push_back(v[i]);
          i++; // skipped following ".."
          doAgain = true;
          continue;
        }
        // remove "foo/.."
        if (i+1 < v.size() && v[i] != ".." && v[i+1] == "..")
        {
          // but as a special case, if the full path is "foo/.." return "."
          if (v.size() == 2) return ".";
          i++;
          doAgain = true;
          continue;
        }
        outv.push_back(v[i]);
      }
      if (doAgain) 
      {
        v = outv;
        outv.clear();
      }
    }
    return Path::join(outv.begin(), outv.end());

  }
예제 #20
0
LuaPlus::LuaObject ant::LuaStateManager::createPath( const std::string& path, bool ignoreLastElement /*= false*/ )
{
	StringVec splitPath;
	Split(path,splitPath, '.');
	if (ignoreLastElement)
	{
		splitPath.pop_back();
	}

	LuaPlus::LuaObject context = getGlobalVars();
	for (auto it = splitPath.begin() ; it != splitPath.end() ; it++)
	{
		// Is the context valid?
		if (context.IsNil())
		{
			GCC_ERROR("Something broke in CreatePath(); bailing out (element == " + (*it) + ")");
			return context;  // this will be nil
		}

		// grab whatever exists for this element
		const std::string& element = (*it);
		LuaPlus::LuaObject curr = context.GetByName(element.c_str());

		if (!curr.IsTable())
		{
			// if the element is not a table and not nil, we clobber it
			if (!curr.IsNil())
			{
				GCC_WARNING("Overwriting element '" + element + "' in table");
				context.SetNil(element.c_str());
			}

			// element is either nil or was clobbered so add the new table
			context.CreateTable(element.c_str());
		}

		context = context.GetByName(element.c_str());
	}

	// We have created a complete path here
	return context;
}
예제 #21
0
static String expandRecursivePath(const String& path, const String& prefix, const VariableCollectionHierarchy& vch)
{
  // Check if recursive expansion is necessary
  if (!strEndsWith(path, "/**"))
    return addPrefixQuoted(path, prefix, vch);
  
  // Remove the pesky /** ending
  String fixedPath = path.substr(0, path.length() - 3);
  
  // Expand the path and get an absolute project path
  String expandedPath = vch.expand(fixedPath);
  String projectPath = vch.getValue("PROJECT_DIR");
  
  // Make an absolute path
  String absPath = joinPaths(projectPath, expandedPath);
  
  // Get a list of subdirectories to ignore
  StringVec ignoreList;
  vch.getValue("EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES", ignoreList);

  // Get recursive paths
  StringVec dirVec;
  getRecursiveDirList(absPath, dirVec, ignoreList);
  
  // Sort the paths such that they are in breadth-first, alphabetic order
  std::sort(dirVec.begin(), dirVec.end(), compare_nocase_breadth_first);

  // Substitute back the original form of the path (which likely contains variables)
  String ret;
  for (unsigned i = 0; i < dirVec.size(); i++) {
    dirVec[i].replace(0, absPath.length(), fixedPath);
    ret += addPrefixQuoted(dirVec[i], prefix, vch);
  }

  // Check that the recursive expansion succeeded
  if (dirVec.empty()) {
    SBLog::info() << "Failed recursive expansion of \"" << absPath << "\". Path does not exist." << std::endl;
    return "";
  } else { 
    return ret;
  }
}
예제 #22
0
bool parseIntegerVec(std::string str, IntegerVec& intVector)
{
	StringVec strVector = explodeString(str, ";");
	IntegerVec tmpIntVector;
	for(StringVec::iterator it = strVector.begin(); it != strVector.end(); ++it)
	{
		tmpIntVector = vectorAtoi(explodeString((*it), "-"));
		if(!tmpIntVector[0] && it->substr(0, 1) != "0")
			continue;

		intVector.push_back(tmpIntVector[0]);
		if(tmpIntVector.size() > 1)
		{
			while(tmpIntVector[0] < tmpIntVector[1])
				intVector.push_back(++tmpIntVector[0]);
		}
	}

	return true;
}
예제 #23
0
std::string parseVocationString(StringVec vocStringVec)
{
	std::string str = "";
	if(!vocStringVec.empty())
	{
		for(StringVec::iterator it = vocStringVec.begin(); it != vocStringVec.end(); ++it)
		{
			if((*it) != vocStringVec.front())
			{
				if((*it) != vocStringVec.back())
					str += ", ";
				else
					str += " and ";
			}

			str += (*it);
			str += "s";
		}
	}

	return str;
}
예제 #24
0
파일: otserv.cpp 프로젝트: 081421/otxserver
bool argumentsHandler(StringVec args)
{
	StringVec tmp;
	for(StringVec::iterator it = args.begin(); it != args.end(); ++it)
	{
		if((*it) == "--help")
		{
			std::clog << "Usage:\n"
			"\n"
			"\t--config=$1\t\tAlternate configuration file path.\n"
			"\t--data-directory=$1\tAlternate data directory path.\n"
			"\t--ip=$1\t\t\tIP address of the server.\n"
			"\t\t\t\tShould be equal to the global IP.\n"
			"\t--login-port=$1\tPort for login server to listen on.\n"
			"\t--game-port=$1\tPort for game server to listen on.\n"
			"\t--admin-port=$1\tPort for admin server to listen on.\n"
			"\t--manager-port=$1\tPort for manager server to listen on.\n"
			"\t--status-port=$1\tPort for status server to listen on.\n";
#ifndef WINDOWS
			std::clog << "\t--runfile=$1\t\tSpecifies run file. Will contain the pid\n"
			"\t\t\t\tof the server process as long as run status.\n";
#endif
			std::clog << "\t--log=$1\t\tWhole standard output will be logged to\n"
			"\t\t\t\tthis file.\n"
			"\t--closed\t\t\tStarts the server as closed.\n"
			"\t--no-script\t\t\tStarts the server without script system.\n";
			return false;
		}

		if((*it) == "--version" || (*it) == "-v")
		{
			std::clog << "The " << SOFTWARE_NAME << " Version: (" << SOFTWARE_VERSION << "." << MINOR_VERSION << PATCH_VERSION << " - " << REVISION_VERSION << ") - Codename: (" << SOFTWARE_CODENAME << ")\n"
			"Compilied with " << BOOST_COMPILER << " for arch "
			#if defined(__amd64__) || defined(_M_X64)
			"64 Bits"
			#elif defined(__i386__) || defined(_M_IX86) || defined(_X86_)
			"32 Bits"
			#else
			"unk"
			#endif
			" at " << __DATE__ << " " << __TIME__ << "\n"

			"\n"
			"A server developed by: "SOFTWARE_DEVELOPERS".\n"
			"Visit our forums for updates, support, and resources:\n"
			""FORUMS"\n";
			return false;
		}

		tmp = explodeString((*it), "=");
		if(tmp[0] == "--config")
			g_config.setString(ConfigManager::CONFIG_FILE, tmp[1]);
		else if(tmp[0] == "--data-directory")
			g_config.setString(ConfigManager::DATA_DIRECTORY, tmp[1]);
		else if(tmp[0] == "--logs-directory")
			g_config.setString(ConfigManager::LOGS_DIRECTORY, tmp[1]);
		else if(tmp[0] == "--ip")
			g_config.setString(ConfigManager::IP, tmp[1]);
		else if(tmp[0] == "--login-port")
			g_config.setNumber(ConfigManager::LOGIN_PORT, atoi(tmp[1].c_str()));
		else if(tmp[0] == "--game-port")
			g_config.setNumber(ConfigManager::GAME_PORT, atoi(tmp[1].c_str()));
		else if(tmp[0] == "--status-port")
			g_config.setNumber(ConfigManager::STATUS_PORT, atoi(tmp[1].c_str()));
#ifndef WINDOWS
		else if(tmp[0] == "--runfile" || tmp[0] == "--run-file" || tmp[0] == "--pidfile" || tmp[0] == "--pid-file")
			g_config.setString(ConfigManager::RUNFILE, tmp[1]);
#endif
		else if(tmp[0] == "--log")
			g_config.setString(ConfigManager::OUTPUT_LOG, tmp[1]);
#ifndef WINDOWS
		else if(tmp[0] == "--daemon" || tmp[0] == "-d")
			g_config.setBool(ConfigManager::DAEMONIZE, true);
#endif
		else if(tmp[0] == "--closed")
			g_config.setBool(ConfigManager::START_CLOSED, true);
		else if(tmp[0] == "--no-script" || tmp[0] == "--noscript")
			g_config.setBool(ConfigManager::SCRIPT_SYSTEM, false);
	}

	return true;
}
예제 #25
0
int VtModelParser::Load(
	const xtime::TimeSlice &time,
	Engine &engine,
	const pkg::Asset::Ref &asset,
	int flags
) {
	const String *s = asset->entry->KeyValue<String>("AnimStates.Source", P_TARGET_FLAGS(flags));
	if (!s)
		return SR_MetaError;

	m_statesRef = engine.sys->packages->Resolve(s->c_str, asset->zone);
	if (!m_statesRef)
		return SR_FileNotFound;

	int r = m_statesRef->Process(
		xtime::TimeSlice::Infinite,
		flags
	);

	if (r != SR_Success)
		return r;

	m_states = SkAnimStatesParser::Cast(m_statesRef);
	if (!m_states || !m_states->valid)
		return SR_ParseError;

	s = asset->entry->KeyValue<String>("Mesh.Source.File", P_TARGET_FLAGS(flags));
	if (!s)
		return SR_MetaError;

	file::MMFileInputBuffer::Ref ib = engine.sys->files->OpenInputBuffer(s->c_str, ZTools);
	if (!ib)
		return SR_FileNotFound;

	stream::InputStream is(*ib);

	tools::SceneFile mesh;
	if (!tools::LoadSceneFile(is, mesh, true))
		return SR_ParseError;

	ib.reset();

	if (mesh.worldspawn->models.size() != 1) {
		COut(C_Error) << "ERROR: 3DX file should only contain 1 model, it contains " << mesh.worldspawn->models.size() << ". File: '" << *s << "'" << std::endl;
		return SR_ParseError;
	}

	s = asset->entry->KeyValue<String>("Anims.Source.File", P_TARGET_FLAGS(flags));
	if (!s)
		return SR_MetaError;

	StringVec animSources;
	SkAnimSetParser::LoadToolsFile(s->c_str, engine, &animSources, 0);

	if (animSources.empty())
		return SR_ParseError;

	tools::SceneFileVec anims;
	for (StringVec::const_iterator it = animSources.begin(); it != animSources.end(); ++it) {
		ib = engine.sys->files->OpenInputBuffer((*it).c_str, ZTools);
		if (!ib)
			return SR_FileNotFound;
		stream::InputStream is(*ib);
		tools::SceneFileRef x(new (tools::Z3DX) tools::SceneFile());
		if (!tools::LoadSceneFile(is, *x, true))
			return SR_ParseError;
		anims.push_back(x);
	}

	m_vtmd = tools::CompileVtmData(
		asset->path,
		mesh,
		anims,
		0
	);

	return m_vtmd ? SR_Success : SR_ParseError;
}
예제 #26
0
void SBSourcesBuildPhase::writeVCProjectFiles(VCProject& proj) const
{
  // We don't support source compilation when building bundles
  TargetProductType productType = m_parentTarget.getProductType();
  if (productType == TargetBundle)
  {
    if (!m_phase->getBuildFileList().empty()) {
      SBLog::warning() << "Ignoring all source files in \"" << m_parentTarget.getName() << "\" bundle target." << std::endl;
    }
    return;
  }

  SBBuildPhase::writeVSFileDescriptions(proj, "Text");

  String xcProjectDir = m_parentTarget.getProject().getProjectDir();
  String vsProjectDir = sb_dirname(proj.getPath());
  StringSet prefixHeaders;
  for (auto bs : m_parentTarget.getBuildSettings()) {
    VCProjectConfiguration* config = proj.addConfiguration(bs.first);

    // Prefix header (recalculate relative path)
    String prefixHeader = bs.second->getValue("GCC_PREFIX_HEADER");
    if (!prefixHeader.empty()) {
      String absHeaderPath = m_parentTarget.makeAbsolutePath(prefixHeader);
      String relHeaderPath = m_parentTarget.makeRelativePath(prefixHeader, vsProjectDir);;
      relHeaderPath = winPath(relHeaderPath);
      config->setItemDefinition("ClangCompile", "PrefixHeader", relHeaderPath);

      // Add plist file to project (only once)
      if (prefixHeaders.find(absHeaderPath) == prefixHeaders.end()) {
        addRelativeFilePathToVS("ClInclude", absHeaderPath, "", proj, *bs.second);
        prefixHeaders.insert(absHeaderPath);
      }
    }

    // Preprocessor definitions
    StringVec preprocessorTokens;
    bs.second->getValue("GCC_PREPROCESSOR_DEFINITIONS", preprocessorTokens);
    String preprocessorDefs = joinStrings(preprocessorTokens, ";");
    if (!preprocessorDefs.empty()) {
      config->setItemDefinition("ClangCompile", "PreprocessorDefinitions", preprocessorDefs);
    }

    // Optimization level
    String optimizationLevel = bs.second->getValue("GCC_OPTIMIZATION_LEVEL");
    if (!optimizationLevel.empty()) {
      String vsOptimizationLevel;
      if (optimizationLevel == "s") {
        vsOptimizationLevel = "MinSpace";
      } else if (optimizationLevel == "0") {
        vsOptimizationLevel = "Disabled";
      } else {
        vsOptimizationLevel = "MaxSpeed";
      }
      config->setItemDefinition("ClangCompile", "OptimizationLevel", vsOptimizationLevel);
    }

    // ARC
    String enableARC = bs.second->getValue("CLANG_ENABLE_OBJC_ARC");
    if (enableARC == "YES") {
      config->setItemDefinition("ClangCompile", "ObjectiveCARC", "true");
    }

    // Modules
    String enableModules = bs.second->getValue("CLANG_ENABLE_MODULES");
    if (enableModules == "YES") {
        config->setItemDefinition("ClangCompile", "ObjectiveCModules", "true");
    }

    // Header search paths (make them relative)
    StringVec includePaths;
    bs.second->getValue("HEADER_SEARCH_PATHS", includePaths);
    for (auto &cur : includePaths) {
      cur = m_parentTarget.makeRelativePath(cur, vsProjectDir);
      cur = winPath(cur);
    }
    includePaths.insert(includePaths.begin(), "$(SolutionPublicHeadersDir)");
    config->setItemDefinition("ClangCompile", "IncludePaths", joinStrings(includePaths, ";"));

    // User header search paths (make them relative)
    StringVec userIncludePaths;
    bs.second->getValue("USER_HEADER_SEARCH_PATHS", userIncludePaths);
    for (auto &cur : userIncludePaths) {
      cur = m_parentTarget.makeRelativePath(cur, vsProjectDir);
      cur = winPath(cur);
    }
    if (!userIncludePaths.empty()) {
      config->setItemDefinition("ClangCompile", "UserIncludePaths", joinStrings(userIncludePaths, ";"));
    }

    // Exclude search path subdirectories
    StringVec excludeSubDirectories;
    bs.second->getValue("EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES", excludeSubDirectories);
    if (!excludeSubDirectories.empty()) {
        config->setItemDefinition("ClangCompile", "ExcludedSearchPathSubdirectories", joinStrings(excludeSubDirectories, ";"));
    }

    // Header map
    if (bs.second->getValue("USE_HEADERMAP") == "YES") {
      if (bs.second->getValue("ALWAYS_SEARCH_USER_PATHS") == "YES") {
        config->setItemDefinition("ClangCompile", "HeaderMap", "Combined");
      } else if (bs.second->getValue("HEADERMAP_INCLUDES_PROJECT_HEADERS") == "YES") {
        config->setItemDefinition("ClangCompile", "HeaderMap", "Project");
      }
    }

    // Other C flags
    String otherCFlags = bs.second->getValue("OTHER_CFLAGS");
    processClangFlags(otherCFlags, xcProjectDir, vsProjectDir);
    if (!otherCFlags.empty()) {
      config->setItemDefinition("ClangCompile", "OtherCFlags", otherCFlags);
    }

    // Other C++ flags
    String otherCPlusPlusFlags = bs.second->getValue("OTHER_CPLUSPLUSFLAGS");
    processClangFlags(otherCPlusPlusFlags, xcProjectDir, vsProjectDir);
    if (!otherCPlusPlusFlags.empty()) {
      config->setItemDefinition("ClangCompile", "OtherCPlusPlusFlags", otherCPlusPlusFlags);
    }

    // CRT
    String configNameUpper = strToUpper(bs.first);
    if (configNameUpper.find("DEBUG") != String::npos) {
      config->setItemDefinition("ClangCompile", "RuntimeLibrary", "MultiThreadedDebugDLL");
    }
  }
}
예제 #27
0
/*static*/ bool StructureParser::test_matchVariableDefinition () {
	// Test 1 regular variable
	{
		StringVec v = createStringVec ("int a");
		VariableDefinition d;
		bool result = matchVariableDefinition (v.begin(), v.end(), &d);
		if (!result || d.name != "a" || d.type.name != "int" || d.type.const_ || d.type.static_ || d.type.mutable_){
			fprintf (stderr, "test_matchVariableDefinition1 failed\n");
			return false;
		}
	}
	// Test 2 variable with additional modifiers
	{
		StringVec v = createStringVec ("static mutable const int var");
		VariableDefinition d;
		bool result = matchVariableDefinition (v.begin(), v.end(), &d);
		if (!result || d.name != "var" || d.type.name != "int" || !d.type.const_ || !d.type.static_ || !d.type.mutable_){
			fprintf (stderr, "test_matchVariableDefinition2 failed\n");
			return false;
		}
	}
	// Test 3 complex variable type
	{
		StringVec v = createStringVec ("static std :: pair < string , int > var");
		VariableDefinition d;
		bool result = matchVariableDefinition (v.begin(), v.end(), &d);
		if (!result || d.name != "var" || d.type.name != "std::pair < string , int >" || d.type.const_ || !d.type.static_ || d.type.mutable_){
			fprintf (stderr, "test_matchVariableDefinition3 failed\n");
			return false;
		}
	}
	// Test 4 not a variable defintion but a function
	{
		StringVec v = createStringVec ("static const int getNumber ( )");
		VariableDefinition d;
		bool result = matchVariableDefinition (v.begin(), v.end(), &d);
		if (result){
			fprintf (stderr, "test_matchVariableDefinition4 failed: %s\n", sf::toJSON(d).c_str());
			return false;
		}
	}
	// Test 5 not a variable defintion but a forward definition
	{
		StringVec v = createStringVec ("class x");
		VariableDefinition d;
		bool result = matchVariableDefinition (v.begin(), v.end(), &d);
		if (result){
			fprintf (stderr, "test_matchVariableDefinition5 failed: %s\n", sf::toJSON(d).c_str());
			return false;
		}
	}
	// Test 6 not a variable defintion but a typedef
	{
		StringVec v = createStringVec ("typedef std :: vector < MyType > MyTypeVec");
		VariableDefinition d;
		bool result = matchVariableDefinition (v.begin(), v.end(), &d);
		if (result){
			fprintf (stderr, "test_matchVariableDefinition6 failed: %s\n", sf::toJSON(d).c_str());
			return false;
		}
	}
	// Test 7 Variable names may also contains '_' (regression)
	{
		StringVec v = createStringVec ("int bla_");
		VariableDefinition d;
		bool result = matchVariableDefinition (v.begin(), v.end(), &d);
		if (!result || d.name != "bla_" || d.type.name != "int") {
			fprintf (stderr, "test_matchVariableDefinition7 failed, %s\n", sf::toJSON(d).c_str());
			return false;
		}
	}
	return true;
}
예제 #28
0
/*static*/ bool StructureParser::test_matchFunctionDeclaration () {
	// Test 1 simple
	{
		StringVec v = createStringVec ("void helloWorld ( )");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (!result || element.name != "helloWorld" || element.returnType.name != "void") {
			fprintf (stderr, "test_matchFunctionDeclaration1 failed\n");
			return false;
		}
	}
	// Test2 const method
	{
		StringVec v = createStringVec ("void helloWorld ( ) const");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (!result || element.name != "helloWorld" || element.returnType.name != "void" || !element.const_) {
			fprintf (stderr, "test_matchFunctionDeclaration2 failed\n");
			return false;
		}
	}
	// Test3 simple argument
	{
		StringVec v = createStringVec ("void func ( int a )");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (!result || element.name != "func" || element.returnType.name != "void" || element.const_ || element.arguments.size() != 1) {
			fprintf (stderr, "test_matchFunctionDeclaration3 failed: %s\n", sf::toJSON(element).c_str());
			return false;
		}
	}
	// Test4 two arguments
	{
		StringVec v = createStringVec ("void func ( int a , const std::string & b )");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (!result || element.name != "func" || element.returnType.name != "void" || element.const_ || element.arguments.size () != 2) {
			fprintf (stderr, "test_matchFunctionDeclaration4 failed\n");
			return false;
		}
	}
	// Test5 two arguments, omitting name
	{
		StringVec v = createStringVec ("void func ( int , const std::string & )");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (!result || element.name != "func" || element.returnType.name != "void" || element.const_ || element.arguments.size () != 2) {
			fprintf (stderr, "test_matchFunctionDeclaration5 failed\n");
			return false;
		}
	}
	// Test6 complex return value
	{
		StringVec v = createStringVec ("const std :: string < char > & func ( const int & a , std :: vector < int > & b ) const");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (!result || element.name != "func" || element.returnType.name != "std::string < char > &" || !element.returnType.const_ || element.arguments.size() != 2
			|| element.arguments[0].type.name != "int &" || !element.arguments[0].type.const_ || element.arguments[1].type.name != "std::vector < int > &" || element.arguments[1].type.const_){
			fprintf (stderr, "test_matchFunctionDeclaration6 failed: %d %s\n", result, sf::toJSON(element).c_str());
			return false;
		}
	}
	// Test 7 a function pointer
	{
		StringVec v = createStringVec ("int ( * MyFunction ) ( )");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (result) {
			fprintf (stderr, "test_matchFunctionDeclaration7 failed\n");
			return false;
		}
	}
	// Test 8 a c++ function pointer
	{
		StringVec v = createStringVec ("int ( MyClass :: * pointer ) ( )");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (result) {
			fprintf (stderr, "test_matchFunctionDeclaration8 failed\n");
			return false;
		}
	}
	// Test 9 a virtual function
	{
		StringVec v = createStringVec ("virtual int bla ( )");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (!result || !element.virtual_) {
			fprintf (stderr, "test_matchFunctionDeclaration9 failed\n");
			return false;
		}
	}
	// Test 10 a inline function
	{
		StringVec v = createStringVec ("inline int bla ( )");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (!result || !element.inline_) {
			fprintf (stderr, "test_matchFunctionDeclaration10 failed\n");
			return false;
		}
	}
	// Test 11 an abstract function
	{
		StringVec v = createStringVec ("virtual int bla ( ) = 0");
		FunctionDeclarationElement element;
		bool result = matchFunctionDeclaration (v.begin(), v.end(), &element);
		if (!result || !element.abstract || !element.virtual_) {
			fprintf (stderr, "test_matchFunctionDeclaration11 failed\n");
			return false;
		}
	}


	return true;
}
예제 #29
0
bool argumentsHandler(StringVec args)
{
	StringVec tmp;
	for(StringVec::iterator it = args.begin(); it != args.end(); ++it)
	{
		if((*it) == "--help")
		{
			std::cout << "Usage:\n"
			"\n"
			"\t--config=$1\t\tAlternate configuration file path.\n"
			"\t--data-directory=$1\tAlternate data directory path.\n"
			"\t--ip=$1\t\t\tIP address of gameworld server.\n"
			"\t\t\t\tShould be equal to the global IP.\n"
			"\t--login-port=$1\tPort for login server to listen on.\n"
			"\t--game-port=$1\tPort for game server to listen on.\n"
			"\t--admin-port=$1\tPort for admin server to listen on.\n"
			"\t--status-port=$1\tPort for status server to listen on.\n";
#ifndef WINDOWS
			std::cout << "\t--runfile=$1\t\tSpecifies run file. Will contain the pid\n"
			"\t\t\t\tof the server process as long as it is running.\n";
#endif
			std::cout << "\t--output-log=$1\t\tAll standard output will be logged to\n"
			"\t\t\t\tthis file.\n"
			"\t--error-log=$1\t\tAll standard errors will be logged to\n"
			"\t\t\t\tthis file.\n";
			return false;
		}

		if((*it) == "--version")
		{
			std::cout << STATUS_SERVER_NAME << ", version " << STATUS_SERVER_VERSION << " (" << STATUS_SERVER_CODENAME << ")\n"
			"Compiled with " << BOOST_COMPILER << " at " << __DATE__ << ", " << __TIME__ << ".\n"
			"A server developed by Elf, slawkens, Talaturen, Lithium, KaczooH, Kiper, Kornholijo.\n"
			"Visit our forum for updates, support and resources: http://otland.net.\n";
			return false;
		}

		tmp = explodeString((*it), "=");
		if(tmp[0] == "--config")
			g_config.setString(ConfigManager::CONFIG_FILE, tmp[1]);
		else if(tmp[0] == "--data-directory")
			g_config.setString(ConfigManager::DATA_DIRECTORY, tmp[1]);
		else if(tmp[0] == "--ip")
			g_config.setString(ConfigManager::IP, tmp[1]);
		else if(tmp[0] == "--login-port")
			g_config.setNumber(ConfigManager::LOGIN_PORT, atoi(tmp[1].c_str()));
		else if(tmp[0] == "--game-port")
			g_config.setNumber(ConfigManager::GAME_PORT, atoi(tmp[1].c_str()));
		else if(tmp[0] == "--admin-port")
			g_config.setNumber(ConfigManager::ADMIN_PORT, atoi(tmp[1].c_str()));
		else if(tmp[0] == "--status-port")
			g_config.setNumber(ConfigManager::STATUS_PORT, atoi(tmp[1].c_str()));
#ifndef WINDOWS
		else if(tmp[0] == "--runfile")
			g_config.setString(ConfigManager::RUNFILE, tmp[1]);
#endif
		else if(tmp[0] == "--output-log")
			g_config.setString(ConfigManager::OUT_LOG, tmp[1]);
		else if(tmp[0] == "--error-log")
			g_config.setString(ConfigManager::ERROR_LOG, tmp[1]);
	}

	return true;
}
예제 #30
0
bool argumentsHandler(StringVec args)
{
	StringVec tmp;
	for(StringVec::iterator it = args.begin(); it != args.end(); ++it)
	{
		if((*it) == "--help")
		{
			std::clog << "Usage:\n"
			"\n"
			"\t--config=$1\t\tAlternate configuration file path.\n"
			"\t--data-directory=$1\tAlternate data directory path.\n"
			"\t--ip=$1\t\t\tIP address of the server.\n"
			"\t\t\t\tShould be equal to the global IP.\n"
			"\t--login-port=$1\tPort for login server to listen on.\n"
			"\t--game-port=$1\tPort for game server to listen on.\n"
			"\t--admin-port=$1\tPort for admin server to listen on.\n"
			"\t--manager-port=$1\tPort for manager server to listen on.\n"
			"\t--status-port=$1\tPort for status server to listen on.\n";
#ifndef WINDOWS
			std::clog << "\t--runfile=$1\t\tSpecifies run file. Will contain the pid\n"
			"\t\t\t\tof the server process as long as run status.\n";
#endif
			std::clog << "\t--log=$1\t\tWhole standard output will be logged to\n"
			"\t\t\t\tthis file.\n"
			"\t--closed\t\t\tStarts the server as closed.\n";
			return false;
		}

		if((*it) == "--version")
		{
			std::clog << SOFTWARE_NAME << " " << SOFTWARE_VERSION << std::endl << std::endl;
			return false;
		}

		tmp = explodeString((*it), "=");
		if(tmp[0] == "--config")
			g_config.setString(ConfigManager::CONFIG_FILE, tmp[1]);
		else if(tmp[0] == "--data-directory")
			g_config.setString(ConfigManager::DATA_DIRECTORY, tmp[1]);
		else if(tmp[0] == "--ip")
			g_config.setString(ConfigManager::IP, tmp[1]);
		else if(tmp[0] == "--login-port")
			g_config.setNumber(ConfigManager::LOGIN_PORT, atoi(tmp[1].c_str()));
		else if(tmp[0] == "--game-port")
			g_config.setNumber(ConfigManager::GAME_PORT, atoi(tmp[1].c_str()));
		else if(tmp[0] == "--admin-port")
			g_config.setNumber(ConfigManager::ADMIN_PORT, atoi(tmp[1].c_str()));
		else if(tmp[0] == "--manager-port")
			g_config.setNumber(ConfigManager::MANAGER_PORT, atoi(tmp[1].c_str()));
		else if(tmp[0] == "--status-port")
			g_config.setNumber(ConfigManager::STATUS_PORT, atoi(tmp[1].c_str()));
#ifndef WINDOWS
		else if(tmp[0] == "--runfile")
			g_config.setString(ConfigManager::RUNFILE, tmp[1]);
#endif
		else if(tmp[0] == "--log")
			g_config.setString(ConfigManager::OUTPUT_LOG, tmp[1]);
		else if(tmp[0] == "--closed")
			g_config.setBool(ConfigManager::START_CLOSED, true);
		else if(tmp[0] == "--no-script")
			g_config.setBool(ConfigManager::SCRIPT_SYSTEM, false);
	}

	return true;
}