FeeScaleXML * procFeeScale(std::string &line) { FeeScaleXML * xml = new FeeScaleXML(); interval feeInterval; feeInterval.lowerLimit = "true"; feeInterval.upperLimit = "true"; std::string name(line, 50, 9); std::string firstPos(line, 32, 7); std::string secondPos(line, 32, 7); //std::cout << line.substr(10, 7) << std::endl; xml->name = name; xml->currency = "THB"; xml->baseValue = "F"; xml->calculationBase = "E"; xml->calculationMethod = "L"; xml->overlappingIntervals = "N"; xml->FeeAggregationScheme = "Client Aggregation"; xml->intervals.push_back(feeInterval); if (line.substr(10, 7) == "STOCKFT") { //Single Stock //std::cout << "Single Stock" << std::endl ; xml->orderEstimationMode = "S"; return xml; } else if (line.substr(21, 1) == "2") { //std::cout << "NON SINGLE STOCK : NO TIER" << std::endl ; xml->orderEstimationMode = "F"; return xml; } // In others cases,return NULL return NULL; }
bool Collision::checkCollides(Object* _first, Object* _second, Game* _game) { sf::Vector2f depth(0, 0); sf::Vector2f normal(0, 0); sf::IntRect first = _first->getAABB(); sf::IntRect second = _second->getAABB(); sf::Vector2i firstPos((int)_first->getX() + first.width, (int)_first->getY() + first.height); sf::Vector2i secondPos((int)_second->getX() + second.width, (int)_second->getY() + second.height); int dx = firstPos.x - secondPos.x; int dy = firstPos.y - secondPos.y; int adx = abs(firstPos.x - secondPos.x); int ady = abs(firstPos.y - secondPos.y); int sw = (first.width + second.width); int sh = (first.height + second.height); if((adx < sw) && (ady < sh)) { float invDist = 1.0f / (float)sqrt(dx * dx + dy * dy); normal = getNormal(sf::Vector2f(dx * invDist, dy * invDist)); depth = sf::Vector2f((float)abs(adx - sw), (float)abs(ady - sh)); _first->collisionCallback(depth, normal, _second, _game); _second->collisionCallback(depth, normal, _first, _game); _first->collide(); _second->collide(); return true; } return false; }
void procFeeScaleFromTier(std::string &line,std::vector<FeeScaleXML*> &FeeSclaeList) { FeeScaleXML * xml = new FeeScaleXML(); std::string name(line, 0, 10); std::string firstPos(line, 32, 7); std::string secondPos(line, 32, 7); std::string lowerLimit(line, 10, 5); std::string upperLimit(line, 15, 5); std::string FirstValue(line, 20, 8); std::string SecondValue(line, 28, 8); std::string val="0"; if (FirstValue != "0000.00") { val = FirstValue; } else if (SecondValue != "0000.00"){ val = SecondValue; } if (FeeSclaeList.size() != 0){ interval feeInterval; feeInterval.value = val; feeInterval.upperLimit = upperLimit; std::vector<FeeScaleXML*>::iterator it = FeeSclaeList.end(); --it; if (name.compare((*it)->name) != 0) { //New Fee tier ,set upper limit of last fee as "true" std::vector<interval>::iterator feeIt = (*it)->intervals.end(); --feeIt; feeIt->upperLimit = "true"; feeInterval.lowerLimit = "true"; xml->name = name; xml->description = "description"; xml->currency = "THB"; xml->baseValue = "F"; xml->calculationBase = "A"; xml->calculationMethod = "L"; xml->orderEstimationMode = "F"; xml->overlappingIntervals = "N"; xml->intervals.push_back(feeInterval); xml->FeeAggregationScheme="Client Aggregation"; FeeSclaeList.push_back(xml); } else { // Fee existed ,adds more tier std::vector<interval>::iterator feeIt = (*it)->intervals.end(); --feeIt; feeInterval.lowerLimit = lowerLimit; (*it)->intervals.push_back(feeInterval); } } /* */ }