TEST_F(FSTestFixture, getAllFiles_without_extsFilter)
	{
		std::vector<Path> content;
		std::vector<Path> content0;

		Path path(getTestDirectory().string(), "", false);
		Path path0((getTestDirectory() / "0").string(), "", false);

		getAllFiles(path, content, nullptr);
		getAllFiles(path0, content0, nullptr);

		ASSERT_EQ(content.size(), 0);
		ASSERT_EQ(content0.size(), 4);


		ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / "0").string(), "", true), content0));
		ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / "1.txt").string(), "", true), content0));
		ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / "2.png").string(), "", true), content0));
		ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / UNICODE_EXAMPLE_FILE).string(), "", true), content0));
	}
示例#2
0
void RecursiveTileScan(Tile &currentTile,TileLevel &level,std::vector<Tile> &foundTiles, int searchValue,std::vector<std::pair<int,int>> *oldPosition)
{
  if(searchValue >= alphaOffset)
    foundTiles.push_back(currentTile);

  oldPosition->push_back(std::make_pair(currentTile.x,currentTile.y));

  for(int x = currentTile.x - 1; x <= currentTile.x + 1; x++)
  {
    for(int y = currentTile.y - 1; y <= currentTile.y + 1; y++)
    {
      if( (x == 0 && y == 0) || isInVector(oldPosition,x,y) )
        continue;

      Tile *tile = level.GetTile(x,y);

      if(tile != NULL && tile->aValue != 255 && (tile->aValue == currentTile.aValue || (currentTile.aValue < alphaOffset && tile->aValue == currentTile.aValue + alphaOffset)))
      {
        RecursiveTileScan(*tile,level,foundTiles,tile->aValue,oldPosition);
      }
    }
  }
}
void visualStudioProject::addAddon(ofAddon & addon){
    for(int i=0;i<(int)addons.size();i++){
		if(addons[i].name==addon.name) return;
	}

	addons.push_back(addon);

    for(int i=0;i<(int)addon.includePaths.size();i++){
        ofLogVerbose() << "adding addon include path: " << addon.includePaths[i];
        addInclude(addon.includePaths[i]);
    }

    // divide libs into debug and release libs
    // the most reliable would be to have seperate
    // folders for debug and release libs
    // i'm gonna start with a ghetto approach of just
    // looking for duplicate names except for a d.lib
    // at the end -> this is not great as many
    // libs compile with the d somewhere in the middle of the name...

    vector <string> debugLibs;
    vector <string> releaseLibs;

    vector <string> possibleReleaseOrDebugOnlyLibs;

    for(int i = 0; i < addon.libs.size(); i++){

        size_t found = 0;

        // get the full lib name
#ifdef TARGET_WIN32
    	found = addon.libs[i].find_last_of("\\");
#else
        found = addon.libs[i].find_last_of("/");
#endif

        string libName = addon.libs[i].substr(found+1);
        // get the first part of a lib name ie., libodd.lib -> libodd OR liboddd.lib -> liboddd
        found = libName.find_last_of(".");
        string firstPart = libName.substr(0,found);

        // check this lib name against every other lib name
        for(int j = 0; j < addon.libs.size(); j++){
            // check if this lib name is contained within another lib name and is not the same name
            if(ofIsStringInString(addon.libs[j], firstPart) && addon.libs[i] != addon.libs[j]){
                // if it is then add respecitive libs to debug and release
                if(!isInVector(addon.libs[j], debugLibs)){
                    //cout << "adding to DEBUG " << addon.libs[j] << endl;
                    debugLibs.push_back(addon.libs[j]);
                }
                if(!isInVector(addon.libs[i], releaseLibs)){
                    //cout << "adding to RELEASE " << addon.libs[i] << endl;
                    releaseLibs.push_back(addon.libs[i]);
                }
                // stop searching
                break;
            }else{
                // if we only have a release or only have a debug lib
                // we'll want to add it to both releaseLibs and debugLibs
                // NB: all debug libs will get added to this vector,
                // but we catch that once all pairs have been added
                // since we cannot guarantee the order of parsing libs
                // although this is innefficient it fixes issues on linux
                if(!isInVector(addon.libs[i], possibleReleaseOrDebugOnlyLibs)){
                    possibleReleaseOrDebugOnlyLibs.push_back(addon.libs[i]);
                }
                // keep searching...
            }
        }
    }

    for(int i=0;i<(int)possibleReleaseOrDebugOnlyLibs.size();i++){
         if(!isInVector(possibleReleaseOrDebugOnlyLibs[i], debugLibs) && !isInVector(possibleReleaseOrDebugOnlyLibs[i], releaseLibs)){
            ofLogVerbose() << "RELEASE ONLY LIBS FOUND " << possibleReleaseOrDebugOnlyLibs[i] << endl;
            debugLibs.push_back(possibleReleaseOrDebugOnlyLibs[i]);
            releaseLibs.push_back(possibleReleaseOrDebugOnlyLibs[i]);
         }
    }

    for(int i=0;i<(int)debugLibs.size();i++){
        ofLogVerbose() << "adding addon debug libs: " << debugLibs[i];
        addLibrary(debugLibs[i], DEBUG_LIB);
    }

    for(int i=0;i<(int)releaseLibs.size();i++){
        ofLogVerbose() << "adding addon release libs: " << releaseLibs[i];
        addLibrary(releaseLibs[i], RELEASE_LIB);
    }

    for(int i=0;i<(int)addon.srcFiles.size(); i++){
        ofLogVerbose() << "adding addon srcFiles: " << addon.srcFiles[i];
        addSrc(addon.srcFiles[i],addon.filesToFolders[addon.srcFiles[i]]);
    }
}
示例#4
0
int Parser::doOperationLogic(std::pair<std::string, Token> op, Stack* stack) {
    if(stack->size() < 2)
        return -1;

    /*

     Priority level:
        1. string,
        2. number,
        3. bool

     Object is rather [1 -> 3].

     */

    Object* obj1 = stack->getObject(0);
    Object* obj2 = stack->getObject(-1);
    stack->pop();
    stack->pop();

    if(!obj1 && !obj2)
        return -2; // error
    if(obj1->type == t_null || obj2->type == t_null)
        return -3;

    Token type = t_unknown;

    std::string result = std::to_string(INT_MIN);

    if(obj1->type == t_type_string || obj2->type == t_type_string) {
        type = t_type_string;

        auto first = obj1->getString();
        auto second = obj2->getString();

        switch(op.second) {
        case t_plus:
            result = second + first;
            break;

        case t_asterix:
            result = "";
            if(obj1->type == t_type_number) {
                for(int i = 0; i < std::stoi(first); i++) {
                    result += second;
                }
            } else if(obj2->type == t_type_number) {
                for(int i = 0; i < std::stoi(second); i++) {
                    result += first;
                }
            } else // both are string
                return -5;

            break;

        case t_minus:
        case t_raised:
        case t_forw_slash:
            return -5;
            break;

        case t_equal_to:
            result = std::to_string(second == first);
            break;

        case t_not_equal_to:
            result = std::to_string(second != first);
            break;

        case t_less_than:
            result = std::to_string(second < first);
            break;

        case t_greater_than:
            result = std::to_string(second > first);
            break;

        case t_less_than_or_equal:
            result = std::to_string(second <= first);
            break;

        case t_greater_than_or_equal:
            result = std::to_string(second >= first);
            break;

        default:
            return -4;
        }

    } else if((obj1->type == t_type_number || obj1->type == t_type_bool) && (obj2->type == t_type_number || obj2->type == t_type_bool)) {
        type = t_type_number;
        if(obj1->type == t_type_bool || obj2->type == t_type_bool)
            type = t_type_bool;

        auto first = obj1->getNumber();
        auto second = obj2->getNumber();

        switch(op.second) {
        case t_plus:
            result = std::to_string(second + first);
            break;

        case t_minus:
            result = std::to_string(second - first);
            break;

        case t_forw_slash:
            result = std::to_string(second / first);
            break;

        case t_asterix:
            result = std::to_string(second * first);
            break;

        case t_raised:
            result = std::to_string(pow(second, first));
            break;

        case t_modulo:
            result = std::to_string((int)floor(second) % (int)floor(first));
            break;

        case t_equal_to:
            result = std::to_string(second == first);
            break;

        case t_not_equal_to:
            result = std::to_string(second != first);
            break;

        case t_less_than:
            result = std::to_string(second < first);
            break;

        case t_greater_than:
            result = std::to_string(second > first);
            break;

        case t_less_than_or_equal:
            result = std::to_string(second <= first);
            break;

        case t_greater_than_or_equal:
            result = std::to_string(second >= first);
            break;

        default:
            return -4;
        }
    } else
        return -5;

    std::vector<Token> boolean = {t_equal_to, t_less_than, t_less_than_or_equal, t_greater_than, t_greater_than_or_equal, t_not_equal_to};
    if(isInVector(boolean, op.second))
        type = t_type_bool;

    void* toPush = nullptr;
    switch(type) {
    case t_type_string:
        toPush = (void*)stack->addString(result);
        break;

    case t_type_number:
    case t_type_bool:
        toPush = (void*)stack->addFloat(std::stof(result));
        break;

    default:
        return -5;
        break;
    }
    stack->push(stack->addObject(new Object(toPush, type)));

    return 0; // Success
}